1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-18 08:22:33 +02:00

Apply clang format

This commit is contained in:
Elias Steurer 2021-07-25 15:30:37 +02:00
parent d76cfd9ff4
commit 6cb31ffa3f
57 changed files with 12310 additions and 12998 deletions

View File

@ -47,8 +47,8 @@
#include <QUrl> #include <QUrl>
#include <QtGlobal> #include <QtGlobal>
#include <QtQml> #include <QtQml>
#include <QtWebEngine>
#include <QtSvg> #include <QtSvg>
#include <QtWebEngine>
#include "src/create.h" #include "src/create.h"
#include "src/globalvariables.h" #include "src/globalvariables.h"

View File

@ -17,7 +17,6 @@ ScreenPlayWallpaper::~ScreenPlayWallpaper()
{ {
m_connection->close(); m_connection->close();
qInfo() << "Remove wallpaper " << m_appID; qInfo() << "Remove wallpaper " << m_appID;
} }
/*! /*!

View File

@ -50,10 +50,9 @@ ScreenPlayWidget::ScreenPlayWidget(
QVariant::fromValue(m_type).toString(), QVariant::fromValue(m_type).toString(),
QString::number(m_position.x()), QString::number(m_position.x()),
QString::number(m_position.y()), QString::number(m_position.y()),
}; };
} }
bool ScreenPlayWidget::start() bool ScreenPlayWidget::start()
{ {
m_process.setArguments(m_appArgumentsList); m_process.setArguments(m_appArgumentsList);

View File

@ -18,7 +18,7 @@ ScreenPlay::SDKConnection::SDKConnection(QLocalSocket* socket, QObject* parent)
{ {
m_socket = socket; m_socket = socket;
connect(m_socket, &QLocalSocket::readyRead, this, &SDKConnection::readyRead); connect(m_socket, &QLocalSocket::readyRead, this, &SDKConnection::readyRead);
connect(m_socket, &QLocalSocket::errorOccurred, this, [](QLocalSocket::LocalSocketError socketError){ connect(m_socket, &QLocalSocket::errorOccurred, this, [](QLocalSocket::LocalSocketError socketError) {
qInfo() << "Localsocket error:" << socketError; qInfo() << "Localsocket error:" << socketError;
}); });
} }

View File

@ -201,7 +201,7 @@ public slots:
QFile defaultPListFile(":/assets/macos/" + plistFileName); QFile defaultPListFile(":/assets/macos/" + plistFileName);
defaultPListFile.open(QIODevice::ReadOnly); defaultPListFile.open(QIODevice::ReadOnly);
QString settingsPlistContent = defaultPListFile.readAll(); QString settingsPlistContent = defaultPListFile.readAll();
if(!settingsPlistContent.contains("{{SCREENPLAY_PATH}}")){ if (!settingsPlistContent.contains("{{SCREENPLAY_PATH}}")) {
qCritical() << "Unable to load plist settings template from qrc to set autostart!"; qCritical() << "Unable to load plist settings template from qrc to set autostart!";
} }
@ -211,12 +211,12 @@ public slots:
workingDir.cdUp(); workingDir.cdUp();
const QString screenPlayPath = QUrl::fromUserInput(workingDir.path() + "/ScreenPlay.app/Contents/MacOS/ScreenPlay").toLocalFile(); const QString screenPlayPath = QUrl::fromUserInput(workingDir.path() + "/ScreenPlay.app/Contents/MacOS/ScreenPlay").toLocalFile();
settingsPlistContent.replace("{{SCREENPLAY_PATH}}", screenPlayPath); settingsPlistContent.replace("{{SCREENPLAY_PATH}}", screenPlayPath);
settingsPlistContent.replace("{{SCREENPLAY_AUTOSTART}}", autostart ? "true":"false"); settingsPlistContent.replace("{{SCREENPLAY_AUTOSTART}}", autostart ? "true" : "false");
const QString homePath = QDir::homePath(); const QString homePath = QDir::homePath();
QFile settingsPlist(homePath + "/Library/LaunchAgents/" + plistFileName); QFile settingsPlist(homePath + "/Library/LaunchAgents/" + plistFileName);
if (settingsPlist.exists()) { if (settingsPlist.exists()) {
if(!settingsPlist.remove()){ if (!settingsPlist.remove()) {
qCritical() << "Unable to remove: " << settingsPlist; qCritical() << "Unable to remove: " << settingsPlist;
} }
} }

View File

@ -38,7 +38,7 @@ int main(int argc, char* argv[])
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
LinuxWindow window({ 0 }, "test", "appid", "1", "fill", false); LinuxWindow window({ 0 }, "test", "appid", "1", "fill", false);
#elif defined(Q_OS_OSX) #elif defined(Q_OS_OSX)
MacWindow window({ 0 }, "test", "appID=test", "1", "fill","videoWallpaper", true, true); MacWindow window({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true);
#endif #endif
return app.exec(); return app.exec();
} }
@ -89,14 +89,14 @@ int main(int argc, char* argv[])
checkWallpaperVisible); checkWallpaperVisible);
#elif defined(Q_OS_OSX) #elif defined(Q_OS_OSX)
MacWindow window( MacWindow window(
activeScreensList.value(), activeScreensList.value(),
projectFilePath, projectFilePath,
appID, appID,
volume, volume,
fillmode, fillmode,
type, type,
checkWallpaperVisible, checkWallpaperVisible,
debugMode); debugMode);
#endif #endif
return app.exec(); return app.exec();

View File

@ -357,31 +357,31 @@ private:
private: private:
bool m_checkWallpaperVisible { false }; bool m_checkWallpaperVisible { false };
bool m_visualsPaused { false }; bool m_visualsPaused { false };
bool m_loops { true }; bool m_loops { true };
bool m_isPlaying { true }; bool m_isPlaying { true };
bool m_muted { false }; bool m_muted { false };
bool m_canFade { false }; bool m_canFade { false };
bool m_debugMode { false };
float m_volume { 1.0f }; float m_volume { 1.0f };
float m_playbackRate { 1.0f }; float m_playbackRate { 1.0f };
float m_currentTime { 0.0f }; float m_currentTime { 0.0f };
QString m_contentBasePath;
QString m_projectPath;
QString m_projectSourceFile;
QString m_appID; QString m_appID;
ScreenPlay::InstalledType::InstalledType m_type = ScreenPlay::InstalledType::InstalledType::Unknown;
QString m_OSVersion; QString m_OSVersion;
QString m_fillMode; QString m_fillMode;
int m_width { 0 }; int m_width { 0 };
int m_height { 0 }; int m_height { 0 };
ScreenPlay::InstalledType::InstalledType m_type = ScreenPlay::InstalledType::InstalledType::Unknown;
QVector<int> m_activeScreensList; QVector<int> m_activeScreensList;
QFileSystemWatcher m_fileSystemWatcher; QFileSystemWatcher m_fileSystemWatcher;
QTimer m_liveReloadLimiter; QTimer m_liveReloadLimiter;
QSysInfo m_sysinfo; QSysInfo m_sysinfo;
bool m_debugMode = false;
std::unique_ptr<ScreenPlaySDK> m_sdk; std::unique_ptr<ScreenPlaySDK> m_sdk;
QString m_contentBasePath;
QString m_projectPath;
QString m_projectSourceFile;
QUrl m_projectSourceFileAbsolute; QUrl m_projectSourceFileAbsolute;
}; };

View File

@ -37,6 +37,7 @@
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QFileSystemWatcher>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonParseError> #include <QJsonParseError>
@ -50,7 +51,6 @@
#include <QWindow> #include <QWindow>
#include <QtQuick/QQuickView> #include <QtQuick/QQuickView>
#include <QtQuick/QQuickWindow> #include <QtQuick/QQuickWindow>
#include <QFileSystemWatcher>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QFileSystemWatcher> #include <QFileSystemWatcher>

View File

@ -19,49 +19,45 @@
// This interface lets you detect installed apps for the local Steam client, useful for debugging tools // This interface lets you detect installed apps for the local Steam client, useful for debugging tools
// to offer lists of apps to debug via Steam. // to offer lists of apps to debug via Steam.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamAppList class ISteamAppList {
{
public: public:
virtual uint32 GetNumInstalledApps() = 0; virtual uint32 GetNumInstalledApps() = 0;
virtual uint32 GetInstalledApps( AppId_t *pvecAppID, uint32 unMaxAppIDs ) = 0; virtual uint32 GetInstalledApps(AppId_t* pvecAppID, uint32 unMaxAppIDs) = 0;
virtual int GetAppName( AppId_t nAppID, STEAM_OUT_STRING() char *pchName, int cchNameMax ) = 0; // returns -1 if no name was found virtual int GetAppName(AppId_t nAppID, STEAM_OUT_STRING() char* pchName, int cchNameMax) = 0; // returns -1 if no name was found
virtual int GetAppInstallDir( AppId_t nAppID, char *pchDirectory, int cchNameMax ) = 0; // returns -1 if no dir was found virtual int GetAppInstallDir(AppId_t nAppID, char* pchDirectory, int cchNameMax) = 0; // returns -1 if no dir was found
virtual int GetAppBuildId( AppId_t nAppID ) = 0; // return the buildid of this app, may change at any time based on backend updates to the game virtual int GetAppBuildId(AppId_t nAppID) = 0; // return the buildid of this app, may change at any time based on backend updates to the game
}; };
#define STEAMAPPLIST_INTERFACE_VERSION "STEAMAPPLIST_INTERFACE_VERSION001" #define STEAMAPPLIST_INTERFACE_VERSION "STEAMAPPLIST_INTERFACE_VERSION001"
// Global interface accessor // Global interface accessor
inline ISteamAppList *SteamAppList(); inline ISteamAppList* SteamAppList();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamAppList *, SteamAppList, STEAMAPPLIST_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamAppList*, SteamAppList, STEAMAPPLIST_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: Sent when a new app is installed // Purpose: Sent when a new app is installed
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( SteamAppInstalled_t, k_iSteamAppListCallbacks + 1 ) STEAM_CALLBACK_BEGIN(SteamAppInstalled_t, k_iSteamAppListCallbacks + 1)
STEAM_CALLBACK_MEMBER( 0, AppId_t, m_nAppID ) // ID of the app that installs STEAM_CALLBACK_MEMBER(0, AppId_t, m_nAppID) // ID of the app that installs
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: Sent when an app is uninstalled // Purpose: Sent when an app is uninstalled
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( SteamAppUninstalled_t, k_iSteamAppListCallbacks + 2 ) STEAM_CALLBACK_BEGIN(SteamAppUninstalled_t, k_iSteamAppListCallbacks + 2)
STEAM_CALLBACK_MEMBER( 0, AppId_t, m_nAppID ) // ID of the app that installs STEAM_CALLBACK_MEMBER(0, AppId_t, m_nAppID) // ID of the app that installs
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
#pragma pack(pop)
#pragma pack( pop )
#endif // ISTEAMAPPLIST_H #endif // ISTEAMAPPLIST_H

View File

@ -12,206 +12,191 @@
#include "steam_api_common.h" #include "steam_api_common.h"
const int k_cubAppProofOfPurchaseKeyMax = 240; // max supported length of a legacy cd key const int k_cubAppProofOfPurchaseKeyMax = 240; // max supported length of a legacy cd key
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: interface to app data // Purpose: interface to app data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamApps class ISteamApps {
{
public: public:
virtual bool BIsSubscribed() = 0; virtual bool BIsSubscribed() = 0;
virtual bool BIsLowViolence() = 0; virtual bool BIsLowViolence() = 0;
virtual bool BIsCybercafe() = 0; virtual bool BIsCybercafe() = 0;
virtual bool BIsVACBanned() = 0; virtual bool BIsVACBanned() = 0;
virtual const char *GetCurrentGameLanguage() = 0; virtual const char* GetCurrentGameLanguage() = 0;
virtual const char *GetAvailableGameLanguages() = 0; virtual const char* GetAvailableGameLanguages() = 0;
// only use this member if you need to check ownership of another game related to yours, a demo for example // only use this member if you need to check ownership of another game related to yours, a demo for example
virtual bool BIsSubscribedApp( AppId_t appID ) = 0; virtual bool BIsSubscribedApp(AppId_t appID) = 0;
// Takes AppID of DLC and checks if the user owns the DLC & if the DLC is installed // Takes AppID of DLC and checks if the user owns the DLC & if the DLC is installed
virtual bool BIsDlcInstalled( AppId_t appID ) = 0; virtual bool BIsDlcInstalled(AppId_t appID) = 0;
// returns the Unix time of the purchase of the app // returns the Unix time of the purchase of the app
virtual uint32 GetEarliestPurchaseUnixTime( AppId_t nAppID ) = 0; virtual uint32 GetEarliestPurchaseUnixTime(AppId_t nAppID) = 0;
// Checks if the user is subscribed to the current app through a free weekend // Checks if the user is subscribed to the current app through a free weekend
// This function will return false for users who have a retail or other type of license // This function will return false for users who have a retail or other type of license
// Before using, please ask your Valve technical contact how to package and secure your free weekened // Before using, please ask your Valve technical contact how to package and secure your free weekened
virtual bool BIsSubscribedFromFreeWeekend() = 0; virtual bool BIsSubscribedFromFreeWeekend() = 0;
// Returns the number of DLC pieces for the running app // Returns the number of DLC pieces for the running app
virtual int GetDLCCount() = 0; virtual int GetDLCCount() = 0;
// Returns metadata for DLC by index, of range [0, GetDLCCount()] // Returns metadata for DLC by index, of range [0, GetDLCCount()]
virtual bool BGetDLCDataByIndex( int iDLC, AppId_t *pAppID, bool *pbAvailable, char *pchName, int cchNameBufferSize ) = 0; virtual bool BGetDLCDataByIndex(int iDLC, AppId_t* pAppID, bool* pbAvailable, char* pchName, int cchNameBufferSize) = 0;
// Install/Uninstall control for optional DLC // Install/Uninstall control for optional DLC
virtual void InstallDLC( AppId_t nAppID ) = 0; virtual void InstallDLC(AppId_t nAppID) = 0;
virtual void UninstallDLC( AppId_t nAppID ) = 0; virtual void UninstallDLC(AppId_t nAppID) = 0;
// Request legacy cd-key for yourself or owned DLC. If you are interested in this
// data then make sure you provide us with a list of valid keys to be distributed
// to users when they purchase the game, before the game ships.
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
// the key is available (which may be immediately).
virtual void RequestAppProofOfPurchaseKey( AppId_t nAppID ) = 0;
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch // Request legacy cd-key for yourself or owned DLC. If you are interested in this
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing // data then make sure you provide us with a list of valid keys to be distributed
virtual uint32 GetInstalledDepots( AppId_t appID, DepotId_t *pvecDepots, uint32 cMaxDepots ) = 0; // return installed depots in mount order // to users when they purchase the game, before the game ships.
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
// the key is available (which may be immediately).
virtual void RequestAppProofOfPurchaseKey(AppId_t nAppID) = 0;
// returns current app install folder for AppID, returns folder name length virtual bool GetCurrentBetaName(char* pchName, int cchNameBufferSize) = 0; // returns current beta branch name, 'public' is the default branch
virtual uint32 GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchFolderBufferSize ) = 0; virtual bool MarkContentCorrupt(bool bMissingFilesOnly) = 0; // signal Steam that game files seems corrupt or missing
virtual bool BIsAppInstalled( AppId_t appID ) = 0; // returns true if that app is installed (not necessarily owned) virtual uint32 GetInstalledDepots(AppId_t appID, DepotId_t* pvecDepots, uint32 cMaxDepots) = 0; // return installed depots in mount order
// returns the SteamID of the original owner. If this CSteamID is different from ISteamUser::GetSteamID(),
// the user has a temporary license borrowed via Family Sharing
virtual CSteamID GetAppOwner() = 0;
// Returns the associated launch param if the game is run via steam://run/<appid>//?param1=value1&param2=value2&param3=value3 etc. // returns current app install folder for AppID, returns folder name length
// Parameter names starting with the character '@' are reserved for internal use and will always return and empty string. virtual uint32 GetAppInstallDir(AppId_t appID, char* pchFolder, uint32 cchFolderBufferSize) = 0;
// Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game, virtual bool BIsAppInstalled(AppId_t appID) = 0; // returns true if that app is installed (not necessarily owned)
// but it is advised that you not param names beginning with an underscore for your own features.
// Check for new launch parameters on callback NewUrlLaunchParameters_t
virtual const char *GetLaunchQueryParam( const char *pchKey ) = 0;
// get download progress for optional DLC // returns the SteamID of the original owner. If this CSteamID is different from ISteamUser::GetSteamID(),
virtual bool GetDlcDownloadProgress( AppId_t nAppID, uint64 *punBytesDownloaded, uint64 *punBytesTotal ) = 0; // the user has a temporary license borrowed via Family Sharing
virtual CSteamID GetAppOwner() = 0;
// return the buildid of this app, may change at any time based on backend updates to the game // Returns the associated launch param if the game is run via steam://run/<appid>//?param1=value1&param2=value2&param3=value3 etc.
virtual int GetAppBuildId() = 0; // Parameter names starting with the character '@' are reserved for internal use and will always return and empty string.
// Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game,
// but it is advised that you not param names beginning with an underscore for your own features.
// Check for new launch parameters on callback NewUrlLaunchParameters_t
virtual const char* GetLaunchQueryParam(const char* pchKey) = 0;
// Request all proof of purchase keys for the calling appid and asociated DLC. // get download progress for optional DLC
// A series of AppProofOfPurchaseKeyResponse_t callbacks will be sent with virtual bool GetDlcDownloadProgress(AppId_t nAppID, uint64* punBytesDownloaded, uint64* punBytesTotal) = 0;
// appropriate appid values, ending with a final callback where the m_nAppId
// member is k_uAppIdInvalid (zero).
virtual void RequestAllProofOfPurchaseKeys() = 0;
STEAM_CALL_RESULT( FileDetailsResult_t ) // return the buildid of this app, may change at any time based on backend updates to the game
virtual SteamAPICall_t GetFileDetails( const char* pszFileName ) = 0; virtual int GetAppBuildId() = 0;
// Get command line if game was launched via Steam URL, e.g. steam://run/<appid>//<command line>/. // Request all proof of purchase keys for the calling appid and asociated DLC.
// This method of passing a connect string (used when joining via rich presence, accepting an // A series of AppProofOfPurchaseKeyResponse_t callbacks will be sent with
// invite, etc) is preferable to passing the connect string on the operating system command // appropriate appid values, ending with a final callback where the m_nAppId
// line, which is a security risk. In order for rich presence joins to go through this // member is k_uAppIdInvalid (zero).
// path and not be placed on the OS command line, you must set a value in your app's virtual void RequestAllProofOfPurchaseKeys() = 0;
// configuration on Steam. Ask Valve for help with this.
//
// If game was already running and launched again, the NewUrlLaunchParameters_t will be fired.
virtual int GetLaunchCommandLine( char *pszCommandLine, int cubCommandLine ) = 0;
// Check if user borrowed this game via Family Sharing, If true, call GetAppOwner() to get the lender SteamID STEAM_CALL_RESULT(FileDetailsResult_t)
virtual bool BIsSubscribedFromFamilySharing() = 0; virtual SteamAPICall_t GetFileDetails(const char* pszFileName) = 0;
// check if game is a timed trial with limited playtime // Get command line if game was launched via Steam URL, e.g. steam://run/<appid>//<command line>/.
virtual bool BIsTimedTrial( uint32* punSecondsAllowed, uint32* punSecondsPlayed ) = 0; // This method of passing a connect string (used when joining via rich presence, accepting an
// invite, etc) is preferable to passing the connect string on the operating system command
// line, which is a security risk. In order for rich presence joins to go through this
// path and not be placed on the OS command line, you must set a value in your app's
// configuration on Steam. Ask Valve for help with this.
//
// If game was already running and launched again, the NewUrlLaunchParameters_t will be fired.
virtual int GetLaunchCommandLine(char* pszCommandLine, int cubCommandLine) = 0;
// Check if user borrowed this game via Family Sharing, If true, call GetAppOwner() to get the lender SteamID
virtual bool BIsSubscribedFromFamilySharing() = 0;
// check if game is a timed trial with limited playtime
virtual bool BIsTimedTrial(uint32* punSecondsAllowed, uint32* punSecondsPlayed) = 0;
}; };
#define STEAMAPPS_INTERFACE_VERSION "STEAMAPPS_INTERFACE_VERSION008" #define STEAMAPPS_INTERFACE_VERSION "STEAMAPPS_INTERFACE_VERSION008"
// Global interface accessor // Global interface accessor
inline ISteamApps *SteamApps(); inline ISteamApps* SteamApps();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamApps *, SteamApps, STEAMAPPS_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamApps*, SteamApps, STEAMAPPS_INTERFACE_VERSION);
// Global accessor for the gameserver client // Global accessor for the gameserver client
inline ISteamApps *SteamGameServerApps(); inline ISteamApps* SteamGameServerApps();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamApps *, SteamGameServerApps, STEAMAPPS_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamApps*, SteamGameServerApps, STEAMAPPS_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: posted after the user gains ownership of DLC & that DLC is installed // Purpose: posted after the user gains ownership of DLC & that DLC is installed
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct DlcInstalled_t struct DlcInstalled_t {
{ enum { k_iCallback = k_iSteamAppsCallbacks + 5 };
enum { k_iCallback = k_iSteamAppsCallbacks + 5 }; AppId_t m_nAppID; // AppID of the DLC
AppId_t m_nAppID; // AppID of the DLC
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: possible results when registering an activation code // Purpose: possible results when registering an activation code
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
enum ERegisterActivationCodeResult enum ERegisterActivationCodeResult {
{ k_ERegisterActivationCodeResultOK = 0,
k_ERegisterActivationCodeResultOK = 0, k_ERegisterActivationCodeResultFail = 1,
k_ERegisterActivationCodeResultFail = 1, k_ERegisterActivationCodeResultAlreadyRegistered = 2,
k_ERegisterActivationCodeResultAlreadyRegistered = 2, k_ERegisterActivationCodeResultTimeout = 3,
k_ERegisterActivationCodeResultTimeout = 3, k_ERegisterActivationCodeAlreadyOwned = 4,
k_ERegisterActivationCodeAlreadyOwned = 4,
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: response to RegisterActivationCode() // Purpose: response to RegisterActivationCode()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct RegisterActivationCodeResponse_t struct RegisterActivationCodeResponse_t {
{ enum { k_iCallback = k_iSteamAppsCallbacks + 8 };
enum { k_iCallback = k_iSteamAppsCallbacks + 8 }; ERegisterActivationCodeResult m_eResult;
ERegisterActivationCodeResult m_eResult; uint32 m_unPackageRegistered; // package that was registered. Only set on success
uint32 m_unPackageRegistered; // package that was registered. Only set on success
}; };
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: posted after the user gains executes a Steam URL with command line or query parameters // Purpose: posted after the user gains executes a Steam URL with command line or query parameters
// such as steam://run/<appid>//-commandline/?param1=value1&param2=value2&param3=value3 etc // such as steam://run/<appid>//-commandline/?param1=value1&param2=value2&param3=value3 etc
// while the game is already running. The new params can be queried // while the game is already running. The new params can be queried
// with GetLaunchQueryParam and GetLaunchCommandLine // with GetLaunchQueryParam and GetLaunchCommandLine
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
struct NewUrlLaunchParameters_t struct NewUrlLaunchParameters_t {
{ enum { k_iCallback = k_iSteamAppsCallbacks + 14 };
enum { k_iCallback = k_iSteamAppsCallbacks + 14 };
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: response to RequestAppProofOfPurchaseKey/RequestAllProofOfPurchaseKeys // Purpose: response to RequestAppProofOfPurchaseKey/RequestAllProofOfPurchaseKeys
// for supporting third-party CD keys, or other proof-of-purchase systems. // for supporting third-party CD keys, or other proof-of-purchase systems.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct AppProofOfPurchaseKeyResponse_t struct AppProofOfPurchaseKeyResponse_t {
{ enum { k_iCallback = k_iSteamAppsCallbacks + 21 };
enum { k_iCallback = k_iSteamAppsCallbacks + 21 }; EResult m_eResult;
EResult m_eResult; uint32 m_nAppID;
uint32 m_nAppID; uint32 m_cchKeyLength;
uint32 m_cchKeyLength; char m_rgchKey[k_cubAppProofOfPurchaseKeyMax];
char m_rgchKey[k_cubAppProofOfPurchaseKeyMax];
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: response to GetFileDetails // Purpose: response to GetFileDetails
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct FileDetailsResult_t struct FileDetailsResult_t {
{ enum { k_iCallback = k_iSteamAppsCallbacks + 23 };
enum { k_iCallback = k_iSteamAppsCallbacks + 23 }; EResult m_eResult;
EResult m_eResult; uint64 m_ulFileSize; // original file size in bytes
uint64 m_ulFileSize; // original file size in bytes uint8 m_FileSHA[20]; // original file SHA1 hash
uint8 m_FileSHA[20]; // original file SHA1 hash uint32 m_unFlags; //
uint32 m_unFlags; //
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called for games in Timed Trial mode // Purpose: called for games in Timed Trial mode
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct TimedTrialStatus_t struct TimedTrialStatus_t {
{ enum { k_iCallback = k_iSteamAppsCallbacks + 30 };
enum { k_iCallback = k_iSteamAppsCallbacks + 30 }; AppId_t m_unAppID; // appID
AppId_t m_unAppID; // appID bool m_bIsOffline; // if true, time allowed / played refers to offline time, not total time
bool m_bIsOffline; // if true, time allowed / played refers to offline time, not total time uint32 m_unSecondsAllowed; // how many seconds the app can be played in total
uint32 m_unSecondsAllowed; // how many seconds the app can be played in total uint32 m_unSecondsPlayed; // how many seconds the app was already played
uint32 m_unSecondsPlayed; // how many seconds the app was already played
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMAPPS_H #endif // ISTEAMAPPS_H

View File

@ -1,7 +1,7 @@
//====== Copyright 1996-2008, Valve Corporation, All rights reserved. ======= //====== Copyright 1996-2008, Valve Corporation, All rights reserved. =======
// //
// Purpose: a private, but well versioned, interface to get at critical bits // Purpose: a private, but well versioned, interface to get at critical bits
// of a steam3 appticket - consumed by the simple drm wrapper to let it // of a steam3 appticket - consumed by the simple drm wrapper to let it
// ask about ownership with greater confidence. // ask about ownership with greater confidence.
// //
//============================================================================= //=============================================================================
@ -12,17 +12,15 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: hand out a reasonable "future proof" view of an app ownership ticket // Purpose: hand out a reasonable "future proof" view of an app ownership ticket
// the raw (signed) buffer, and indices into that buffer where the appid and // the raw (signed) buffer, and indices into that buffer where the appid and
// steamid are located. the sizes of the appid and steamid are implicit in // steamid are located. the sizes of the appid and steamid are implicit in
// (each version of) the interface - currently uin32 appid and uint64 steamid // (each version of) the interface - currently uin32 appid and uint64 steamid
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamAppTicket class ISteamAppTicket {
{
public: public:
virtual uint32 GetAppOwnershipTicketData( uint32 nAppID, void *pvBuffer, uint32 cbBufferLength, uint32 *piAppId, uint32 *piSteamId, uint32 *piSignature, uint32 *pcbSignature ) = 0; virtual uint32 GetAppOwnershipTicketData(uint32 nAppID, void* pvBuffer, uint32 cbBufferLength, uint32* piAppId, uint32* piSteamId, uint32* piSignature, uint32* pcbSignature) = 0;
}; };
#define STEAMAPPTICKET_INTERFACE_VERSION "STEAMAPPTICKET_INTERFACE_VERSION001" #define STEAMAPPTICKET_INTERFACE_VERSION "STEAMAPPTICKET_INTERFACE_VERSION001"
#endif // ISTEAMAPPTICKET_H #endif // ISTEAMAPPTICKET_H

View File

@ -24,155 +24,153 @@
// or if you want to implement a multiplexed gameserver where a single process // or if you want to implement a multiplexed gameserver where a single process
// is handling multiple games at once with independent gameserver SteamIDs. // is handling multiple games at once with independent gameserver SteamIDs.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamClient class ISteamClient {
{
public: public:
// Creates a communication pipe to the Steam client. // Creates a communication pipe to the Steam client.
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling // NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
virtual HSteamPipe CreateSteamPipe() = 0; virtual HSteamPipe CreateSteamPipe() = 0;
// Releases a previously created communications pipe // Releases a previously created communications pipe
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling // NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
virtual bool BReleaseSteamPipe( HSteamPipe hSteamPipe ) = 0; virtual bool BReleaseSteamPipe(HSteamPipe hSteamPipe) = 0;
// connects to an existing global user, failing if none exists // connects to an existing global user, failing if none exists
// used by the game to coordinate with the steamUI // used by the game to coordinate with the steamUI
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling // NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
virtual HSteamUser ConnectToGlobalUser( HSteamPipe hSteamPipe ) = 0; virtual HSteamUser ConnectToGlobalUser(HSteamPipe hSteamPipe) = 0;
// used by game servers, create a steam user that won't be shared with anyone else // used by game servers, create a steam user that won't be shared with anyone else
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling // NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
virtual HSteamUser CreateLocalUser( HSteamPipe *phSteamPipe, EAccountType eAccountType ) = 0; virtual HSteamUser CreateLocalUser(HSteamPipe* phSteamPipe, EAccountType eAccountType) = 0;
// removes an allocated user // removes an allocated user
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling // NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
virtual void ReleaseUser( HSteamPipe hSteamPipe, HSteamUser hUser ) = 0; virtual void ReleaseUser(HSteamPipe hSteamPipe, HSteamUser hUser) = 0;
// retrieves the ISteamUser interface associated with the handle // retrieves the ISteamUser interface associated with the handle
virtual ISteamUser *GetISteamUser( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamUser* GetISteamUser(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// retrieves the ISteamGameServer interface associated with the handle // retrieves the ISteamGameServer interface associated with the handle
virtual ISteamGameServer *GetISteamGameServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamGameServer* GetISteamGameServer(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// set the local IP and Port to bind to // set the local IP and Port to bind to
// this must be set before CreateLocalUser() // this must be set before CreateLocalUser()
virtual void SetLocalIPBinding( const SteamIPAddress_t &unIP, uint16 usPort ) = 0; virtual void SetLocalIPBinding(const SteamIPAddress_t& unIP, uint16 usPort) = 0;
// returns the ISteamFriends interface // returns the ISteamFriends interface
virtual ISteamFriends *GetISteamFriends( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamFriends* GetISteamFriends(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns the ISteamUtils interface // returns the ISteamUtils interface
virtual ISteamUtils *GetISteamUtils( HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamUtils* GetISteamUtils(HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns the ISteamMatchmaking interface // returns the ISteamMatchmaking interface
virtual ISteamMatchmaking *GetISteamMatchmaking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamMatchmaking* GetISteamMatchmaking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns the ISteamMatchmakingServers interface // returns the ISteamMatchmakingServers interface
virtual ISteamMatchmakingServers *GetISteamMatchmakingServers( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamMatchmakingServers* GetISteamMatchmakingServers(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns the a generic interface // returns the a generic interface
virtual void *GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual void* GetISteamGenericInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns the ISteamUserStats interface // returns the ISteamUserStats interface
virtual ISteamUserStats *GetISteamUserStats( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamUserStats* GetISteamUserStats(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns the ISteamGameServerStats interface // returns the ISteamGameServerStats interface
virtual ISteamGameServerStats *GetISteamGameServerStats( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamGameServerStats* GetISteamGameServerStats(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns apps interface // returns apps interface
virtual ISteamApps *GetISteamApps( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamApps* GetISteamApps(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// networking // networking
virtual ISteamNetworking *GetISteamNetworking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamNetworking* GetISteamNetworking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// remote storage // remote storage
virtual ISteamRemoteStorage *GetISteamRemoteStorage( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamRemoteStorage* GetISteamRemoteStorage(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// user screenshots // user screenshots
virtual ISteamScreenshots *GetISteamScreenshots( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamScreenshots* GetISteamScreenshots(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// game search // game search
virtual ISteamGameSearch *GetISteamGameSearch( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamGameSearch* GetISteamGameSearch(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Deprecated. Applications should use SteamAPI_RunCallbacks() or SteamGameServer_RunCallbacks() instead. // Deprecated. Applications should use SteamAPI_RunCallbacks() or SteamGameServer_RunCallbacks() instead.
STEAM_PRIVATE_API( virtual void RunFrame() = 0; ) STEAM_PRIVATE_API(virtual void RunFrame() = 0;)
// returns the number of IPC calls made since the last time this function was called // returns the number of IPC calls made since the last time this function was called
// Used for perf debugging so you can understand how many IPC calls your game makes per frame // Used for perf debugging so you can understand how many IPC calls your game makes per frame
// Every IPC call is at minimum a thread context switch if not a process one so you want to rate // Every IPC call is at minimum a thread context switch if not a process one so you want to rate
// control how often you do them. // control how often you do them.
virtual uint32 GetIPCCallCount() = 0; virtual uint32 GetIPCCallCount() = 0;
// API warning handling // API warning handling
// 'int' is the severity; 0 for msg, 1 for warning // 'int' is the severity; 0 for msg, 1 for warning
// 'const char *' is the text of the message // 'const char *' is the text of the message
// callbacks will occur directly after the API function is called that generated the warning or message. // callbacks will occur directly after the API function is called that generated the warning or message.
virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0; virtual void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction) = 0;
// Trigger global shutdown for the DLL // Trigger global shutdown for the DLL
virtual bool BShutdownIfAllPipesClosed() = 0; virtual bool BShutdownIfAllPipesClosed() = 0;
// Expose HTTP interface // Expose HTTP interface
virtual ISteamHTTP *GetISteamHTTP( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamHTTP* GetISteamHTTP(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Deprecated - the ISteamUnifiedMessages interface is no longer intended for public consumption. // Deprecated - the ISteamUnifiedMessages interface is no longer intended for public consumption.
STEAM_PRIVATE_API( virtual void *DEPRECATED_GetISteamUnifiedMessages( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0 ; ) STEAM_PRIVATE_API(virtual void* DEPRECATED_GetISteamUnifiedMessages(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;)
// Exposes the ISteamController interface - deprecated in favor of Steam Input // Exposes the ISteamController interface - deprecated in favor of Steam Input
virtual ISteamController *GetISteamController( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamController* GetISteamController(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Exposes the ISteamUGC interface // Exposes the ISteamUGC interface
virtual ISteamUGC *GetISteamUGC( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamUGC* GetISteamUGC(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// returns app list interface, only available on specially registered apps // returns app list interface, only available on specially registered apps
virtual ISteamAppList *GetISteamAppList( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamAppList* GetISteamAppList(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Music Player
virtual ISteamMusic *GetISteamMusic( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
// Music Player Remote // Music Player
virtual ISteamMusicRemote *GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion) = 0; virtual ISteamMusic* GetISteamMusic(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// html page display // Music Player Remote
virtual ISteamHTMLSurface *GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion) = 0; virtual ISteamMusicRemote* GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Helper functions for internal Steam usage // html page display
STEAM_PRIVATE_API( virtual void DEPRECATED_Set_SteamAPI_CPostAPIResultInProcess( void (*)() ) = 0; ) virtual ISteamHTMLSurface* GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
STEAM_PRIVATE_API( virtual void DEPRECATED_Remove_SteamAPI_CPostAPIResultInProcess( void (*)() ) = 0; )
STEAM_PRIVATE_API( virtual void Set_SteamAPI_CCheckCallbackRegisteredInProcess( SteamAPI_CheckCallbackRegistered_t func ) = 0; )
// inventory // Helper functions for internal Steam usage
virtual ISteamInventory *GetISteamInventory( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; STEAM_PRIVATE_API(virtual void DEPRECATED_Set_SteamAPI_CPostAPIResultInProcess(void (*)()) = 0;)
STEAM_PRIVATE_API(virtual void DEPRECATED_Remove_SteamAPI_CPostAPIResultInProcess(void (*)()) = 0;)
STEAM_PRIVATE_API(virtual void Set_SteamAPI_CCheckCallbackRegisteredInProcess(SteamAPI_CheckCallbackRegistered_t func) = 0;)
// Video // inventory
virtual ISteamVideo *GetISteamVideo( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamInventory* GetISteamInventory(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Parental controls // Video
virtual ISteamParentalSettings *GetISteamParentalSettings( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamVideo* GetISteamVideo(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Exposes the Steam Input interface for controller support // Parental controls
virtual ISteamInput *GetISteamInput( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamParentalSettings* GetISteamParentalSettings(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Steam Parties interface // Exposes the Steam Input interface for controller support
virtual ISteamParties *GetISteamParties( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamInput* GetISteamInput(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
// Steam Remote Play interface // Steam Parties interface
virtual ISteamRemotePlay *GetISteamRemotePlay( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; virtual ISteamParties* GetISteamParties(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
STEAM_PRIVATE_API( virtual void DestroyAllInterfaces() = 0; ) // Steam Remote Play interface
virtual ISteamRemotePlay* GetISteamRemotePlay(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion) = 0;
STEAM_PRIVATE_API(virtual void DestroyAllInterfaces() = 0;)
}; };
#define STEAMCLIENT_INTERFACE_VERSION "SteamClient020" #define STEAMCLIENT_INTERFACE_VERSION "SteamClient020"
#ifndef STEAM_API_EXPORTS #ifndef STEAM_API_EXPORTS
// Global ISteamClient interface accessor // Global ISteamClient interface accessor
inline ISteamClient *SteamClient(); inline ISteamClient* SteamClient();
STEAM_DEFINE_INTERFACE_ACCESSOR( ISteamClient *, SteamClient, SteamInternal_CreateInterface( STEAMCLIENT_INTERFACE_VERSION ), "global", STEAMCLIENT_INTERFACE_VERSION ); STEAM_DEFINE_INTERFACE_ACCESSOR(ISteamClient*, SteamClient, SteamInternal_CreateInterface(STEAMCLIENT_INTERFACE_VERSION), "global", STEAMCLIENT_INTERFACE_VERSION);
// The internal ISteamClient used for the gameserver interface. // The internal ISteamClient used for the gameserver interface.
// (This is actually the same thing. You really shouldn't need to access any of this stuff directly.) // (This is actually the same thing. You really shouldn't need to access any of this stuff directly.)
inline ISteamClient *SteamGameServerClient() { return SteamClient(); } inline ISteamClient* SteamGameServerClient() { return SteamClient(); }
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,63 +12,55 @@
#include "steam_api_common.h" #include "steam_api_common.h"
// list of possible return values from the ISteamGameCoordinator API // list of possible return values from the ISteamGameCoordinator API
enum EGCResults enum EGCResults {
{ k_EGCResultOK = 0,
k_EGCResultOK = 0, k_EGCResultNoMessage = 1, // There is no message in the queue
k_EGCResultNoMessage = 1, // There is no message in the queue k_EGCResultBufferTooSmall = 2, // The buffer is too small for the requested message
k_EGCResultBufferTooSmall = 2, // The buffer is too small for the requested message k_EGCResultNotLoggedOn = 3, // The client is not logged onto Steam
k_EGCResultNotLoggedOn = 3, // The client is not logged onto Steam k_EGCResultInvalidMessage = 4, // Something was wrong with the message being sent with SendMessage
k_EGCResultInvalidMessage = 4, // Something was wrong with the message being sent with SendMessage
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for sending and receiving messages from the Game Coordinator // Purpose: Functions for sending and receiving messages from the Game Coordinator
// for this application // for this application
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamGameCoordinator class ISteamGameCoordinator {
{
public: public:
// sends a message to the Game Coordinator
virtual EGCResults SendMessage(uint32 unMsgType, const void* pubData, uint32 cubData) = 0;
// sends a message to the Game Coordinator // returns true if there is a message waiting from the game coordinator
virtual EGCResults SendMessage( uint32 unMsgType, const void *pubData, uint32 cubData ) = 0; virtual bool IsMessageAvailable(uint32* pcubMsgSize) = 0;
// returns true if there is a message waiting from the game coordinator
virtual bool IsMessageAvailable( uint32 *pcubMsgSize ) = 0;
// fills the provided buffer with the first message in the queue and returns k_EGCResultOK or
// returns k_EGCResultNoMessage if there is no message waiting. pcubMsgSize is filled with the message size.
// If the provided buffer is not large enough to fit the entire message, k_EGCResultBufferTooSmall is returned
// and the message remains at the head of the queue.
virtual EGCResults RetrieveMessage( uint32 *punMsgType, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize ) = 0;
// fills the provided buffer with the first message in the queue and returns k_EGCResultOK or
// returns k_EGCResultNoMessage if there is no message waiting. pcubMsgSize is filled with the message size.
// If the provided buffer is not large enough to fit the entire message, k_EGCResultBufferTooSmall is returned
// and the message remains at the head of the queue.
virtual EGCResults RetrieveMessage(uint32* punMsgType, void* pubDest, uint32 cubDest, uint32* pcubMsgSize) = 0;
}; };
#define STEAMGAMECOORDINATOR_INTERFACE_VERSION "SteamGameCoordinator001" #define STEAMGAMECOORDINATOR_INTERFACE_VERSION "SteamGameCoordinator001"
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
// callback notification - A new message is available for reading from the message queue // callback notification - A new message is available for reading from the message queue
struct GCMessageAvailable_t struct GCMessageAvailable_t {
{ enum { k_iCallback = k_iSteamGameCoordinatorCallbacks + 1 };
enum { k_iCallback = k_iSteamGameCoordinatorCallbacks + 1 }; uint32 m_nMessageSize;
uint32 m_nMessageSize;
}; };
// callback notification - A message failed to make it to the GC. It may be down temporarily // callback notification - A message failed to make it to the GC. It may be down temporarily
struct GCMessageFailed_t struct GCMessageFailed_t {
{ enum { k_iCallback = k_iSteamGameCoordinatorCallbacks + 2 };
enum { k_iCallback = k_iSteamGameCoordinatorCallbacks + 2 };
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMGAMECOORDINATOR #endif // ISTEAMGAMECOORDINATOR

View File

@ -15,362 +15,343 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for authenticating users via Steam to play on a game server // Purpose: Functions for authenticating users via Steam to play on a game server
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamGameServer class ISteamGameServer {
{
public: public:
//
// Basic server data. These properties, if set, must be set before before calling LogOn. They
// may not be changed after logged in.
//
// /// This is called by SteamGameServer_Init, and you will usually not need to call it directly
// Basic server data. These properties, if set, must be set before before calling LogOn. They STEAM_PRIVATE_API(virtual bool InitGameServer(uint32 unIP, uint16 usGamePort, uint16 usQueryPort, uint32 unFlags, AppId_t nGameAppId, const char* pchVersionString) = 0;)
// may not be changed after logged in.
//
/// This is called by SteamGameServer_Init, and you will usually not need to call it directly /// Game product identifier. This is currently used by the master server for version checking purposes.
STEAM_PRIVATE_API( virtual bool InitGameServer( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, uint32 unFlags, AppId_t nGameAppId, const char *pchVersionString ) = 0; ) /// It's a required field, but will eventually will go away, and the AppID will be used for this purpose.
virtual void SetProduct(const char* pszProduct) = 0;
/// Game product identifier. This is currently used by the master server for version checking purposes. /// Description of the game. This is a required field and is displayed in the steam server browser....for now.
/// It's a required field, but will eventually will go away, and the AppID will be used for this purpose. /// This is a required field, but it will go away eventually, as the data should be determined from the AppID.
virtual void SetProduct( const char *pszProduct ) = 0; virtual void SetGameDescription(const char* pszGameDescription) = 0;
/// Description of the game. This is a required field and is displayed in the steam server browser....for now. /// If your game is a "mod," pass the string that identifies it. The default is an empty string, meaning
/// This is a required field, but it will go away eventually, as the data should be determined from the AppID. /// this application is the original game, not a mod.
virtual void SetGameDescription( const char *pszGameDescription ) = 0; ///
/// @see k_cbMaxGameServerGameDir
virtual void SetModDir(const char* pszModDir) = 0;
/// If your game is a "mod," pass the string that identifies it. The default is an empty string, meaning /// Is this is a dedicated server? The default value is false.
/// this application is the original game, not a mod. virtual void SetDedicatedServer(bool bDedicated) = 0;
///
/// @see k_cbMaxGameServerGameDir
virtual void SetModDir( const char *pszModDir ) = 0;
/// Is this is a dedicated server? The default value is false. //
virtual void SetDedicatedServer( bool bDedicated ) = 0; // Login
//
// /// Begin process to login to a persistent game server account
// Login ///
// /// You need to register for callbacks to determine the result of this operation.
/// @see SteamServersConnected_t
/// @see SteamServerConnectFailure_t
/// @see SteamServersDisconnected_t
virtual void LogOn(const char* pszToken) = 0;
/// Begin process to login to a persistent game server account /// Login to a generic, anonymous account.
/// ///
/// You need to register for callbacks to determine the result of this operation. /// Note: in previous versions of the SDK, this was automatically called within SteamGameServer_Init,
/// @see SteamServersConnected_t /// but this is no longer the case.
/// @see SteamServerConnectFailure_t virtual void LogOnAnonymous() = 0;
/// @see SteamServersDisconnected_t
virtual void LogOn( const char *pszToken ) = 0;
/// Login to a generic, anonymous account. /// Begin process of logging game server out of steam
/// virtual void LogOff() = 0;
/// Note: in previous versions of the SDK, this was automatically called within SteamGameServer_Init,
/// but this is no longer the case.
virtual void LogOnAnonymous() = 0;
/// Begin process of logging game server out of steam // status functions
virtual void LogOff() = 0; virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
// status functions virtual CSteamID GetSteamID() = 0;
virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
virtual CSteamID GetSteamID() = 0;
/// Returns true if the master server has requested a restart. /// Returns true if the master server has requested a restart.
/// Only returns true once per request. /// Only returns true once per request.
virtual bool WasRestartRequested() = 0; virtual bool WasRestartRequested() = 0;
// //
// Server state. These properties may be changed at any time. // Server state. These properties may be changed at any time.
// //
/// Max player count that will be reported to server browser and client queries /// Max player count that will be reported to server browser and client queries
virtual void SetMaxPlayerCount( int cPlayersMax ) = 0; virtual void SetMaxPlayerCount(int cPlayersMax) = 0;
/// Number of bots. Default value is zero /// Number of bots. Default value is zero
virtual void SetBotPlayerCount( int cBotplayers ) = 0; virtual void SetBotPlayerCount(int cBotplayers) = 0;
/// Set the name of server as it will appear in the server browser /// Set the name of server as it will appear in the server browser
/// ///
/// @see k_cbMaxGameServerName /// @see k_cbMaxGameServerName
virtual void SetServerName( const char *pszServerName ) = 0; virtual void SetServerName(const char* pszServerName) = 0;
/// Set name of map to report in the server browser /// Set name of map to report in the server browser
/// ///
/// @see k_cbMaxGameServerName /// @see k_cbMaxGameServerName
virtual void SetMapName( const char *pszMapName ) = 0; virtual void SetMapName(const char* pszMapName) = 0;
/// Let people know if your server will require a password /// Let people know if your server will require a password
virtual void SetPasswordProtected( bool bPasswordProtected ) = 0; virtual void SetPasswordProtected(bool bPasswordProtected) = 0;
/// Spectator server. The default value is zero, meaning the service /// Spectator server. The default value is zero, meaning the service
/// is not used. /// is not used.
virtual void SetSpectatorPort( uint16 unSpectatorPort ) = 0; virtual void SetSpectatorPort(uint16 unSpectatorPort) = 0;
/// Name of the spectator server. (Only used if spectator port is nonzero.) /// Name of the spectator server. (Only used if spectator port is nonzero.)
/// ///
/// @see k_cbMaxGameServerMapName /// @see k_cbMaxGameServerMapName
virtual void SetSpectatorServerName( const char *pszSpectatorServerName ) = 0; virtual void SetSpectatorServerName(const char* pszSpectatorServerName) = 0;
/// Call this to clear the whole list of key/values that are sent in rules queries. /// Call this to clear the whole list of key/values that are sent in rules queries.
virtual void ClearAllKeyValues() = 0; virtual void ClearAllKeyValues() = 0;
/// Call this to add/update a key/value pair.
virtual void SetKeyValue( const char *pKey, const char *pValue ) = 0;
/// Sets a string defining the "gametags" for this server, this is optional, but if it is set /// Call this to add/update a key/value pair.
/// it allows users to filter in the matchmaking/server-browser interfaces based on the value virtual void SetKeyValue(const char* pKey, const char* pValue) = 0;
///
/// @see k_cbMaxGameServerTags
virtual void SetGameTags( const char *pchGameTags ) = 0;
/// Sets a string defining the "gamedata" for this server, this is optional, but if it is set /// Sets a string defining the "gametags" for this server, this is optional, but if it is set
/// it allows users to filter in the matchmaking/server-browser interfaces based on the value /// it allows users to filter in the matchmaking/server-browser interfaces based on the value
/// don't set this unless it actually changes, its only uploaded to the master once (when ///
/// acknowledged) /// @see k_cbMaxGameServerTags
/// virtual void SetGameTags(const char* pchGameTags) = 0;
/// @see k_cbMaxGameServerGameData
virtual void SetGameData( const char *pchGameData ) = 0;
/// Region identifier. This is an optional field, the default value is empty, meaning the "world" region /// Sets a string defining the "gamedata" for this server, this is optional, but if it is set
virtual void SetRegion( const char *pszRegion ) = 0; /// it allows users to filter in the matchmaking/server-browser interfaces based on the value
/// don't set this unless it actually changes, its only uploaded to the master once (when
/// acknowledged)
///
/// @see k_cbMaxGameServerGameData
virtual void SetGameData(const char* pchGameData) = 0;
// /// Region identifier. This is an optional field, the default value is empty, meaning the "world" region
// Player list management / authentication virtual void SetRegion(const char* pszRegion) = 0;
//
// Handles receiving a new connection from a Steam user. This call will ask the Steam //
// servers to validate the users identity, app ownership, and VAC status. If the Steam servers // Player list management / authentication
// are off-line, then it will validate the cached ticket itself which will validate app ownership //
// and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
// and must then be sent up to the game server for authentication.
//
// Return Value: returns true if the users ticket passes basic checks. pSteamIDUser will contain the Steam ID of this user. pSteamIDUser must NOT be NULL
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation. // Handles receiving a new connection from a Steam user. This call will ask the Steam
// // servers to validate the users identity, app ownership, and VAC status. If the Steam servers
// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect() // are off-line, then it will validate the cached ticket itself which will validate app ownership
// when this user leaves the server just like you would for a real user. // and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
virtual CSteamID CreateUnauthenticatedUserConnection() = 0; // and must then be sent up to the game server for authentication.
//
// Return Value: returns true if the users ticket passes basic checks. pSteamIDUser will contain the Steam ID of this user. pSteamIDUser must NOT be NULL
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate(uint32 unIPClient, const void* pvAuthBlob, uint32 cubAuthBlobSize, CSteamID* pSteamIDUser) = 0;
// Should be called whenever a user leaves our game server, this lets Steam internally // Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
// track which users are currently on which servers for the purposes of preventing a single //
// account being logged into multiple servers, showing who is currently on a server, etc. // Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0; // when this user leaves the server just like you would for a real user.
virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
// Update the data to be displayed in the server browser and matchmaking interfaces for a user // Should be called whenever a user leaves our game server, this lets Steam internally
// currently connected to the server. For regular users you must call this after you receive a // track which users are currently on which servers for the purposes of preventing a single
// GSUserValidationSuccess callback. // account being logged into multiple servers, showing who is currently on a server, etc.
// virtual void SendUserDisconnect(CSteamID steamIDUser) = 0;
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
// New auth system APIs - do not mix with the old auth system APIs. // Update the data to be displayed in the server browser and matchmaking interfaces for a user
// ---------------------------------------------------------------- // currently connected to the server. For regular users you must call this after you receive a
// GSUserValidationSuccess callback.
//
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData(CSteamID steamIDUser, const char* pchPlayerName, uint32 uScore) = 0;
// Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ). // New auth system APIs - do not mix with the old auth system APIs.
// pcbTicket retrieves the length of the actual ticket. // ----------------------------------------------------------------
virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0;
// Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused // Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ).
// Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse ) // pcbTicket retrieves the length of the actual ticket.
virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0; virtual HAuthTicket GetAuthSessionTicket(void* pTicket, int cbMaxTicket, uint32* pcbTicket) = 0;
// Stop tracking started by BeginAuthSession - called when no longer playing game with this entity // Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused
virtual void EndAuthSession( CSteamID steamID ) = 0; // Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )
virtual EBeginAuthSessionResult BeginAuthSession(const void* pAuthTicket, int cbAuthTicket, CSteamID steamID) = 0;
// Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to // Stop tracking started by BeginAuthSession - called when no longer playing game with this entity
virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0; virtual void EndAuthSession(CSteamID steamID) = 0;
// After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function // Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to
// to determine if the user owns downloadable content specified by the provided AppID. virtual void CancelAuthTicket(HAuthTicket hAuthTicket) = 0;
virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0;
// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t // After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function
// returns false if we're not connected to the steam servers and thus cannot ask // to determine if the user owns downloadable content specified by the provided AppID.
virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0; virtual EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID) = 0;
// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t
// returns false if we're not connected to the steam servers and thus cannot ask
virtual bool RequestUserGroupStatus(CSteamID steamIDUser, CSteamID steamIDGroup) = 0;
// these two functions s are deprecated, and will not return results // these two functions s are deprecated, and will not return results
// they will be removed in a future version of the SDK // they will be removed in a future version of the SDK
virtual void GetGameplayStats( ) = 0; virtual void GetGameplayStats() = 0;
STEAM_CALL_RESULT( GSReputation_t ) STEAM_CALL_RESULT(GSReputation_t)
virtual SteamAPICall_t GetServerReputation() = 0; virtual SteamAPICall_t GetServerReputation() = 0;
// Returns the public IP of the server according to Steam, useful when the server is // Returns the public IP of the server according to Steam, useful when the server is
// behind NAT and you want to advertise its IP in a lobby for other clients to directly // behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to // connect to
virtual SteamIPAddress_t GetPublicIP() = 0; virtual SteamIPAddress_t GetPublicIP() = 0;
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages // socket to talk to the master server on, it lets the game use its socket to forward messages
// back and forth. This prevents us from requiring server ops to open up yet another port // back and forth. This prevents us from requiring server ops to open up yet another port
// in their firewalls. // in their firewalls.
// //
// the IP address and port should be in host order, i.e 127.0.0.1 == 0x7f000001 // the IP address and port should be in host order, i.e 127.0.0.1 == 0x7f000001
// These are used when you've elected to multiplex the game server's UDP socket
// rather than having the master server updater use its own sockets.
//
// Source games use this to simplify the job of the server admins, so they
// don't have to open up more ports on their firewalls.
// Call this when a packet that starts with 0xFFFFFFFF comes in. That means
// it's for us.
virtual bool HandleIncomingPacket( const void *pData, int cbData, uint32 srcIP, uint16 srcPort ) = 0;
// AFTER calling HandleIncomingPacket for any packets that came in that frame, call this. // These are used when you've elected to multiplex the game server's UDP socket
// This gets a packet that the master server updater needs to send out on UDP. // rather than having the master server updater use its own sockets.
// It returns the length of the packet it wants to send, or 0 if there are no more packets to send. //
// Call this each frame until it returns 0. // Source games use this to simplify the job of the server admins, so they
virtual int GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *pNetAdr, uint16 *pPort ) = 0; // don't have to open up more ports on their firewalls.
// // Call this when a packet that starts with 0xFFFFFFFF comes in. That means
// Control heartbeats / advertisement with master server // it's for us.
// virtual bool HandleIncomingPacket(const void* pData, int cbData, uint32 srcIP, uint16 srcPort) = 0;
// Call this as often as you like to tell the master server updater whether or not // AFTER calling HandleIncomingPacket for any packets that came in that frame, call this.
// you want it to be active (default: off). // This gets a packet that the master server updater needs to send out on UDP.
virtual void EnableHeartbeats( bool bActive ) = 0; // It returns the length of the packet it wants to send, or 0 if there are no more packets to send.
// Call this each frame until it returns 0.
virtual int GetNextOutgoingPacket(void* pOut, int cbMaxOut, uint32* pNetAdr, uint16* pPort) = 0;
// You usually don't need to modify this. //
// Pass -1 to use the default value for iHeartbeatInterval. // Control heartbeats / advertisement with master server
// Some mods change this. //
virtual void SetHeartbeatInterval( int iHeartbeatInterval ) = 0;
// Force a heartbeat to steam at the next opportunity // Call this as often as you like to tell the master server updater whether or not
virtual void ForceHeartbeat() = 0; // you want it to be active (default: off).
virtual void EnableHeartbeats(bool bActive) = 0;
// associate this game server with this clan for the purposes of computing player compat // You usually don't need to modify this.
STEAM_CALL_RESULT( AssociateWithClanResult_t ) // Pass -1 to use the default value for iHeartbeatInterval.
virtual SteamAPICall_t AssociateWithClan( CSteamID steamIDClan ) = 0; // Some mods change this.
virtual void SetHeartbeatInterval(int iHeartbeatInterval) = 0;
// ask if any of the current players dont want to play with this new player - or vice versa
STEAM_CALL_RESULT( ComputeNewPlayerCompatibilityResult_t )
virtual SteamAPICall_t ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer ) = 0;
// Force a heartbeat to steam at the next opportunity
virtual void ForceHeartbeat() = 0;
// associate this game server with this clan for the purposes of computing player compat
STEAM_CALL_RESULT(AssociateWithClanResult_t)
virtual SteamAPICall_t AssociateWithClan(CSteamID steamIDClan) = 0;
// ask if any of the current players dont want to play with this new player - or vice versa
STEAM_CALL_RESULT(ComputeNewPlayerCompatibilityResult_t)
virtual SteamAPICall_t ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer) = 0;
}; };
#define STEAMGAMESERVER_INTERFACE_VERSION "SteamGameServer013" #define STEAMGAMESERVER_INTERFACE_VERSION "SteamGameServer013"
// Global accessor // Global accessor
inline ISteamGameServer *SteamGameServer(); inline ISteamGameServer* SteamGameServer();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamGameServer *, SteamGameServer, STEAMGAMESERVER_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamGameServer*, SteamGameServer, STEAMGAMESERVER_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
// client has been approved to connect to this game server // client has been approved to connect to this game server
struct GSClientApprove_t struct GSClientApprove_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 1 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 1 }; CSteamID m_SteamID; // SteamID of approved player
CSteamID m_SteamID; // SteamID of approved player CSteamID m_OwnerSteamID; // SteamID of original owner for game license
CSteamID m_OwnerSteamID; // SteamID of original owner for game license
}; };
// client has been denied to connection to this game server // client has been denied to connection to this game server
struct GSClientDeny_t struct GSClientDeny_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 2 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 2 }; CSteamID m_SteamID;
CSteamID m_SteamID; EDenyReason m_eDenyReason;
EDenyReason m_eDenyReason; char m_rgchOptionalText[128];
char m_rgchOptionalText[128];
}; };
// request the game server should kick the user // request the game server should kick the user
struct GSClientKick_t struct GSClientKick_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 3 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 3 }; CSteamID m_SteamID;
CSteamID m_SteamID; EDenyReason m_eDenyReason;
EDenyReason m_eDenyReason;
}; };
// NOTE: callback values 4 and 5 are skipped because they are used for old deprecated callbacks, // NOTE: callback values 4 and 5 are skipped because they are used for old deprecated callbacks,
// do not reuse them here. // do not reuse them here.
// client achievement info // client achievement info
struct GSClientAchievementStatus_t struct GSClientAchievementStatus_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 6 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 6 }; uint64 m_SteamID;
uint64 m_SteamID; char m_pchAchievement[128];
char m_pchAchievement[128]; bool m_bUnlocked;
bool m_bUnlocked;
}; };
// received when the game server requests to be displayed as secure (VAC protected) // received when the game server requests to be displayed as secure (VAC protected)
// m_bSecure is true if the game server should display itself as secure to users, false otherwise // m_bSecure is true if the game server should display itself as secure to users, false otherwise
struct GSPolicyResponse_t struct GSPolicyResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 15 };
enum { k_iCallback = k_iSteamUserCallbacks + 15 }; uint8 m_bSecure;
uint8 m_bSecure;
}; };
// GS gameplay stats info // GS gameplay stats info
struct GSGameplayStats_t struct GSGameplayStats_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 7 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 7 }; EResult m_eResult; // Result of the call
EResult m_eResult; // Result of the call int32 m_nRank; // Overall rank of the server (0-based)
int32 m_nRank; // Overall rank of the server (0-based) uint32 m_unTotalConnects; // Total number of clients who have ever connected to the server
uint32 m_unTotalConnects; // Total number of clients who have ever connected to the server uint32 m_unTotalMinutesPlayed; // Total number of minutes ever played on the server
uint32 m_unTotalMinutesPlayed; // Total number of minutes ever played on the server
}; };
// send as a reply to RequestUserGroupStatus() // send as a reply to RequestUserGroupStatus()
struct GSClientGroupStatus_t struct GSClientGroupStatus_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 8 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 8 }; CSteamID m_SteamIDUser;
CSteamID m_SteamIDUser; CSteamID m_SteamIDGroup;
CSteamID m_SteamIDGroup; bool m_bMember;
bool m_bMember; bool m_bOfficer;
bool m_bOfficer;
}; };
// Sent as a reply to GetServerReputation() // Sent as a reply to GetServerReputation()
struct GSReputation_t struct GSReputation_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 9 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 9 }; EResult m_eResult; // Result of the call;
EResult m_eResult; // Result of the call; uint32 m_unReputationScore; // The reputation score for the game server
uint32 m_unReputationScore; // The reputation score for the game server bool m_bBanned; // True if the server is banned from the Steam
bool m_bBanned; // True if the server is banned from the Steam // master servers
// master servers
// The following members are only filled out if m_bBanned is true. They will all // The following members are only filled out if m_bBanned is true. They will all
// be set to zero otherwise. Master server bans are by IP so it is possible to be // be set to zero otherwise. Master server bans are by IP so it is possible to be
// banned even when the score is good high if there is a bad server on another port. // banned even when the score is good high if there is a bad server on another port.
// This information can be used to determine which server is bad. // This information can be used to determine which server is bad.
uint32 m_unBannedIP; // The IP of the banned server uint32 m_unBannedIP; // The IP of the banned server
uint16 m_usBannedPort; // The port of the banned server uint16 m_usBannedPort; // The port of the banned server
uint64 m_ulBannedGameID; // The game ID the banned server is serving uint64 m_ulBannedGameID; // The game ID the banned server is serving
uint32 m_unBanExpires; // Time the ban expires, expressed in the Unix epoch (seconds since 1/1/1970) uint32 m_unBanExpires; // Time the ban expires, expressed in the Unix epoch (seconds since 1/1/1970)
}; };
// Sent as a reply to AssociateWithClan() // Sent as a reply to AssociateWithClan()
struct AssociateWithClanResult_t struct AssociateWithClanResult_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 10 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 10 }; EResult m_eResult; // Result of the call;
EResult m_eResult; // Result of the call;
}; };
// Sent as a reply to ComputeNewPlayerCompatibility() // Sent as a reply to ComputeNewPlayerCompatibility()
struct ComputeNewPlayerCompatibilityResult_t struct ComputeNewPlayerCompatibilityResult_t {
{ enum { k_iCallback = k_iSteamGameServerCallbacks + 11 };
enum { k_iCallback = k_iSteamGameServerCallbacks + 11 }; EResult m_eResult; // Result of the call;
EResult m_eResult; // Result of the call; int m_cPlayersThatDontLikeCandidate;
int m_cPlayersThatDontLikeCandidate; int m_cPlayersThatCandidateDoesntLike;
int m_cPlayersThatCandidateDoesntLike; int m_cClanPlayersThatDontLikeCandidate;
int m_cClanPlayersThatDontLikeCandidate; CSteamID m_SteamIDCandidate;
CSteamID m_SteamIDCandidate;
}; };
#pragma pack(pop)
#pragma pack( pop )
#endif // ISTEAMGAMESERVER_H #endif // ISTEAMGAMESERVER_H

View File

@ -15,100 +15,93 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for authenticating users via Steam to play on a game server // Purpose: Functions for authenticating users via Steam to play on a game server
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamGameServerStats class ISteamGameServerStats {
{
public: public:
// downloads stats for the user // downloads stats for the user
// returns a GSStatsReceived_t callback when completed // returns a GSStatsReceived_t callback when completed
// if the user has no stats, GSStatsReceived_t.m_eResult will be set to k_EResultFail // if the user has no stats, GSStatsReceived_t.m_eResult will be set to k_EResultFail
// these stats will only be auto-updated for clients playing on the server. For other // these stats will only be auto-updated for clients playing on the server. For other
// users you'll need to call RequestUserStats() again to refresh any data // users you'll need to call RequestUserStats() again to refresh any data
STEAM_CALL_RESULT( GSStatsReceived_t ) STEAM_CALL_RESULT(GSStatsReceived_t)
virtual SteamAPICall_t RequestUserStats( CSteamID steamIDUser ) = 0; virtual SteamAPICall_t RequestUserStats(CSteamID steamIDUser) = 0;
// requests stat information for a user, usable after a successful call to RequestUserStats() // requests stat information for a user, usable after a successful call to RequestUserStats()
STEAM_FLAT_NAME( GetUserStatInt32 ) STEAM_FLAT_NAME(GetUserStatInt32)
virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) = 0; virtual bool GetUserStat(CSteamID steamIDUser, const char* pchName, int32* pData) = 0;
STEAM_FLAT_NAME( GetUserStatFloat ) STEAM_FLAT_NAME(GetUserStatFloat)
virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) = 0; virtual bool GetUserStat(CSteamID steamIDUser, const char* pchName, float* pData) = 0;
virtual bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved ) = 0; virtual bool GetUserAchievement(CSteamID steamIDUser, const char* pchName, bool* pbAchieved) = 0;
// Set / update stats and achievements. // Set / update stats and achievements.
// Note: These updates will work only on stats game servers are allowed to edit and only for // Note: These updates will work only on stats game servers are allowed to edit and only for
// game servers that have been declared as officially controlled by the game creators. // game servers that have been declared as officially controlled by the game creators.
// Set the IP range of your official servers on the Steamworks page // Set the IP range of your official servers on the Steamworks page
STEAM_FLAT_NAME( SetUserStatInt32 ) STEAM_FLAT_NAME(SetUserStatInt32)
virtual bool SetUserStat( CSteamID steamIDUser, const char *pchName, int32 nData ) = 0; virtual bool SetUserStat(CSteamID steamIDUser, const char* pchName, int32 nData) = 0;
STEAM_FLAT_NAME( SetUserStatFloat ) STEAM_FLAT_NAME(SetUserStatFloat)
virtual bool SetUserStat( CSteamID steamIDUser, const char *pchName, float fData ) = 0; virtual bool SetUserStat(CSteamID steamIDUser, const char* pchName, float fData) = 0;
virtual bool UpdateUserAvgRateStat( CSteamID steamIDUser, const char *pchName, float flCountThisSession, double dSessionLength ) = 0; virtual bool UpdateUserAvgRateStat(CSteamID steamIDUser, const char* pchName, float flCountThisSession, double dSessionLength) = 0;
virtual bool SetUserAchievement( CSteamID steamIDUser, const char *pchName ) = 0; virtual bool SetUserAchievement(CSteamID steamIDUser, const char* pchName) = 0;
virtual bool ClearUserAchievement( CSteamID steamIDUser, const char *pchName ) = 0; virtual bool ClearUserAchievement(CSteamID steamIDUser, const char* pchName) = 0;
// Store the current data on the server, will get a GSStatsStored_t callback when set. // Store the current data on the server, will get a GSStatsStored_t callback when set.
// //
// If the callback has a result of k_EResultInvalidParam, one or more stats // If the callback has a result of k_EResultInvalidParam, one or more stats
// uploaded has been rejected, either because they broke constraints // uploaded has been rejected, either because they broke constraints
// or were out of date. In this case the server sends back updated values. // or were out of date. In this case the server sends back updated values.
// The stats should be re-iterated to keep in sync. // The stats should be re-iterated to keep in sync.
STEAM_CALL_RESULT( GSStatsStored_t ) STEAM_CALL_RESULT(GSStatsStored_t)
virtual SteamAPICall_t StoreUserStats( CSteamID steamIDUser ) = 0; virtual SteamAPICall_t StoreUserStats(CSteamID steamIDUser) = 0;
}; };
#define STEAMGAMESERVERSTATS_INTERFACE_VERSION "SteamGameServerStats001" #define STEAMGAMESERVERSTATS_INTERFACE_VERSION "SteamGameServerStats001"
// Global accessor // Global accessor
inline ISteamGameServerStats *SteamGameServerStats(); inline ISteamGameServerStats* SteamGameServerStats();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamGameServerStats *, SteamGameServerStats, STEAMGAMESERVERSTATS_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamGameServerStats*, SteamGameServerStats, STEAMGAMESERVERSTATS_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when the latests stats and achievements have been received // Purpose: called when the latests stats and achievements have been received
// from the server // from the server
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GSStatsReceived_t struct GSStatsReceived_t {
{ enum { k_iCallback = k_iSteamGameServerStatsCallbacks };
enum { k_iCallback = k_iSteamGameServerStatsCallbacks }; EResult m_eResult; // Success / error fetching the stats
EResult m_eResult; // Success / error fetching the stats CSteamID m_steamIDUser; // The user for whom the stats are retrieved for
CSteamID m_steamIDUser; // The user for whom the stats are retrieved for
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result of a request to store the user stats for a game // Purpose: result of a request to store the user stats for a game
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GSStatsStored_t struct GSStatsStored_t {
{ enum { k_iCallback = k_iSteamGameServerStatsCallbacks + 1 };
enum { k_iCallback = k_iSteamGameServerStatsCallbacks + 1 }; EResult m_eResult; // success / error
EResult m_eResult; // success / error CSteamID m_steamIDUser; // The user for whom the stats were stored
CSteamID m_steamIDUser; // The user for whom the stats were stored
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback indicating that a user's stats have been unloaded. // Purpose: Callback indicating that a user's stats have been unloaded.
// Call RequestUserStats again to access stats for this user // Call RequestUserStats again to access stats for this user
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GSStatsUnloaded_t struct GSStatsUnloaded_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 }; CSteamID m_steamIDUser; // User whose stats have been unloaded
CSteamID m_steamIDUser; // User whose stats have been unloaded
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMGAMESERVERSTATS_H #endif // ISTEAMGAMESERVERSTATS_H

View File

@ -18,223 +18,217 @@ const uint32 INVALID_HTMLBROWSER = 0;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for displaying HTML pages and interacting with them // Purpose: Functions for displaying HTML pages and interacting with them
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamHTMLSurface class ISteamHTMLSurface {
{
public: public:
virtual ~ISteamHTMLSurface() {} virtual ~ISteamHTMLSurface() { }
// Must call init and shutdown when starting/ending use of the interface // Must call init and shutdown when starting/ending use of the interface
virtual bool Init() = 0; virtual bool Init() = 0;
virtual bool Shutdown() = 0; virtual bool Shutdown() = 0;
// Create a browser object for display of a html page, when creation is complete the call handle // Create a browser object for display of a html page, when creation is complete the call handle
// will return a HTML_BrowserReady_t callback for the HHTMLBrowser of your new browser. // will return a HTML_BrowserReady_t callback for the HHTMLBrowser of your new browser.
// The user agent string is a substring to be added to the general user agent string so you can // The user agent string is a substring to be added to the general user agent string so you can
// identify your client on web servers. // identify your client on web servers.
// The userCSS string lets you apply a CSS style sheet to every displayed page, leave null if // The userCSS string lets you apply a CSS style sheet to every displayed page, leave null if
// you do not require this functionality. // you do not require this functionality.
// //
// YOU MUST HAVE IMPLEMENTED HANDLERS FOR HTML_BrowserReady_t, HTML_StartRequest_t, // YOU MUST HAVE IMPLEMENTED HANDLERS FOR HTML_BrowserReady_t, HTML_StartRequest_t,
// HTML_JSAlert_t, HTML_JSConfirm_t, and HTML_FileOpenDialog_t! See the CALLBACKS // HTML_JSAlert_t, HTML_JSConfirm_t, and HTML_FileOpenDialog_t! See the CALLBACKS
// section of this interface (AllowStartRequest, etc) for more details. If you do // section of this interface (AllowStartRequest, etc) for more details. If you do
// not implement these callback handlers, the browser may appear to hang instead of // not implement these callback handlers, the browser may appear to hang instead of
// navigating to new pages or triggering javascript popups. // navigating to new pages or triggering javascript popups.
// //
STEAM_CALL_RESULT( HTML_BrowserReady_t ) STEAM_CALL_RESULT(HTML_BrowserReady_t)
virtual SteamAPICall_t CreateBrowser( const char *pchUserAgent, const char *pchUserCSS ) = 0; virtual SteamAPICall_t CreateBrowser(const char* pchUserAgent, const char* pchUserCSS) = 0;
// Call this when you are done with a html surface, this lets us free the resources being used by it // Call this when you are done with a html surface, this lets us free the resources being used by it
virtual void RemoveBrowser( HHTMLBrowser unBrowserHandle ) = 0; virtual void RemoveBrowser(HHTMLBrowser unBrowserHandle) = 0;
// Navigate to this URL, results in a HTML_StartRequest_t as the request commences // Navigate to this URL, results in a HTML_StartRequest_t as the request commences
virtual void LoadURL( HHTMLBrowser unBrowserHandle, const char *pchURL, const char *pchPostData ) = 0; virtual void LoadURL(HHTMLBrowser unBrowserHandle, const char* pchURL, const char* pchPostData) = 0;
// Tells the surface the size in pixels to display the surface // Tells the surface the size in pixels to display the surface
virtual void SetSize( HHTMLBrowser unBrowserHandle, uint32 unWidth, uint32 unHeight ) = 0; virtual void SetSize(HHTMLBrowser unBrowserHandle, uint32 unWidth, uint32 unHeight) = 0;
// Stop the load of the current html page // Stop the load of the current html page
virtual void StopLoad( HHTMLBrowser unBrowserHandle ) = 0; virtual void StopLoad(HHTMLBrowser unBrowserHandle) = 0;
// Reload (most likely from local cache) the current page // Reload (most likely from local cache) the current page
virtual void Reload( HHTMLBrowser unBrowserHandle ) = 0; virtual void Reload(HHTMLBrowser unBrowserHandle) = 0;
// navigate back in the page history // navigate back in the page history
virtual void GoBack( HHTMLBrowser unBrowserHandle ) = 0; virtual void GoBack(HHTMLBrowser unBrowserHandle) = 0;
// navigate forward in the page history // navigate forward in the page history
virtual void GoForward( HHTMLBrowser unBrowserHandle ) = 0; virtual void GoForward(HHTMLBrowser unBrowserHandle) = 0;
// add this header to any url requests from this browser // add this header to any url requests from this browser
virtual void AddHeader( HHTMLBrowser unBrowserHandle, const char *pchKey, const char *pchValue ) = 0; virtual void AddHeader(HHTMLBrowser unBrowserHandle, const char* pchKey, const char* pchValue) = 0;
// run this javascript script in the currently loaded page // run this javascript script in the currently loaded page
virtual void ExecuteJavascript( HHTMLBrowser unBrowserHandle, const char *pchScript ) = 0; virtual void ExecuteJavascript(HHTMLBrowser unBrowserHandle, const char* pchScript) = 0;
enum EHTMLMouseButton enum EHTMLMouseButton {
{ eHTMLMouseButton_Left = 0,
eHTMLMouseButton_Left = 0, eHTMLMouseButton_Right = 1,
eHTMLMouseButton_Right = 1, eHTMLMouseButton_Middle = 2,
eHTMLMouseButton_Middle = 2, };
};
// Mouse click and mouse movement commands // Mouse click and mouse movement commands
virtual void MouseUp( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; virtual void MouseUp(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) = 0;
virtual void MouseDown( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; virtual void MouseDown(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) = 0;
virtual void MouseDoubleClick( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; virtual void MouseDoubleClick(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) = 0;
// x and y are relative to the HTML bounds // x and y are relative to the HTML bounds
virtual void MouseMove( HHTMLBrowser unBrowserHandle, int x, int y ) = 0; virtual void MouseMove(HHTMLBrowser unBrowserHandle, int x, int y) = 0;
// nDelta is pixels of scroll // nDelta is pixels of scroll
virtual void MouseWheel( HHTMLBrowser unBrowserHandle, int32 nDelta ) = 0; virtual void MouseWheel(HHTMLBrowser unBrowserHandle, int32 nDelta) = 0;
enum EMouseCursor enum EMouseCursor {
{ dc_user = 0,
dc_user = 0, dc_none,
dc_none, dc_arrow,
dc_arrow, dc_ibeam,
dc_ibeam, dc_hourglass,
dc_hourglass, dc_waitarrow,
dc_waitarrow, dc_crosshair,
dc_crosshair, dc_up,
dc_up, dc_sizenw,
dc_sizenw, dc_sizese,
dc_sizese, dc_sizene,
dc_sizene, dc_sizesw,
dc_sizesw, dc_sizew,
dc_sizew, dc_sizee,
dc_sizee, dc_sizen,
dc_sizen, dc_sizes,
dc_sizes, dc_sizewe,
dc_sizewe, dc_sizens,
dc_sizens, dc_sizeall,
dc_sizeall, dc_no,
dc_no, dc_hand,
dc_hand, dc_blank, // don't show any custom cursor, just use your default
dc_blank, // don't show any custom cursor, just use your default dc_middle_pan,
dc_middle_pan, dc_north_pan,
dc_north_pan, dc_north_east_pan,
dc_north_east_pan, dc_east_pan,
dc_east_pan, dc_south_east_pan,
dc_south_east_pan, dc_south_pan,
dc_south_pan, dc_south_west_pan,
dc_south_west_pan, dc_west_pan,
dc_west_pan, dc_north_west_pan,
dc_north_west_pan, dc_alias,
dc_alias, dc_cell,
dc_cell, dc_colresize,
dc_colresize, dc_copycur,
dc_copycur, dc_verticaltext,
dc_verticaltext, dc_rowresize,
dc_rowresize, dc_zoomin,
dc_zoomin, dc_zoomout,
dc_zoomout, dc_help,
dc_help, dc_custom,
dc_custom,
dc_last, // custom cursors start from this value and up dc_last, // custom cursors start from this value and up
}; };
enum EHTMLKeyModifiers enum EHTMLKeyModifiers {
{ k_eHTMLKeyModifier_None = 0,
k_eHTMLKeyModifier_None = 0, k_eHTMLKeyModifier_AltDown = 1 << 0,
k_eHTMLKeyModifier_AltDown = 1 << 0, k_eHTMLKeyModifier_CtrlDown = 1 << 1,
k_eHTMLKeyModifier_CtrlDown = 1 << 1, k_eHTMLKeyModifier_ShiftDown = 1 << 2,
k_eHTMLKeyModifier_ShiftDown = 1 << 2, };
};
// keyboard interactions, native keycode is the virtual key code value from your OS, system key flags the key to not // keyboard interactions, native keycode is the virtual key code value from your OS, system key flags the key to not
// be sent as a typed character as well as a key down // be sent as a typed character as well as a key down
virtual void KeyDown( HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers, bool bIsSystemKey = false ) = 0; virtual void KeyDown(HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers, bool bIsSystemKey = false) = 0;
virtual void KeyUp( HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0; virtual void KeyUp(HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers) = 0;
// cUnicodeChar is the unicode character point for this keypress (and potentially multiple chars per press) // cUnicodeChar is the unicode character point for this keypress (and potentially multiple chars per press)
virtual void KeyChar( HHTMLBrowser unBrowserHandle, uint32 cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0; virtual void KeyChar(HHTMLBrowser unBrowserHandle, uint32 cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers) = 0;
// programmatically scroll this many pixels on the page // programmatically scroll this many pixels on the page
virtual void SetHorizontalScroll( HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll ) = 0; virtual void SetHorizontalScroll(HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll) = 0;
virtual void SetVerticalScroll( HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll ) = 0; virtual void SetVerticalScroll(HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll) = 0;
// tell the html control if it has key focus currently, controls showing the I-beam cursor in text controls amongst other things // tell the html control if it has key focus currently, controls showing the I-beam cursor in text controls amongst other things
virtual void SetKeyFocus( HHTMLBrowser unBrowserHandle, bool bHasKeyFocus ) = 0; virtual void SetKeyFocus(HHTMLBrowser unBrowserHandle, bool bHasKeyFocus) = 0;
// open the current pages html code in the local editor of choice, used for debugging // open the current pages html code in the local editor of choice, used for debugging
virtual void ViewSource( HHTMLBrowser unBrowserHandle ) = 0; virtual void ViewSource(HHTMLBrowser unBrowserHandle) = 0;
// copy the currently selected text on the html page to the local clipboard // copy the currently selected text on the html page to the local clipboard
virtual void CopyToClipboard( HHTMLBrowser unBrowserHandle ) = 0; virtual void CopyToClipboard(HHTMLBrowser unBrowserHandle) = 0;
// paste from the local clipboard to the current html page // paste from the local clipboard to the current html page
virtual void PasteFromClipboard( HHTMLBrowser unBrowserHandle ) = 0; virtual void PasteFromClipboard(HHTMLBrowser unBrowserHandle) = 0;
// find this string in the browser, if bCurrentlyInFind is true then instead cycle to the next matching element // find this string in the browser, if bCurrentlyInFind is true then instead cycle to the next matching element
virtual void Find( HHTMLBrowser unBrowserHandle, const char *pchSearchStr, bool bCurrentlyInFind, bool bReverse ) = 0; virtual void Find(HHTMLBrowser unBrowserHandle, const char* pchSearchStr, bool bCurrentlyInFind, bool bReverse) = 0;
// cancel a currently running find // cancel a currently running find
virtual void StopFind( HHTMLBrowser unBrowserHandle ) = 0; virtual void StopFind(HHTMLBrowser unBrowserHandle) = 0;
// return details about the link at position x,y on the current page // return details about the link at position x,y on the current page
virtual void GetLinkAtPosition( HHTMLBrowser unBrowserHandle, int x, int y ) = 0; virtual void GetLinkAtPosition(HHTMLBrowser unBrowserHandle, int x, int y) = 0;
// set a webcookie for the hostname in question // set a webcookie for the hostname in question
virtual void SetCookie( const char *pchHostname, const char *pchKey, const char *pchValue, const char *pchPath = "/", RTime32 nExpires = 0, bool bSecure = false, bool bHTTPOnly = false ) = 0; virtual void SetCookie(const char* pchHostname, const char* pchKey, const char* pchValue, const char* pchPath = "/", RTime32 nExpires = 0, bool bSecure = false, bool bHTTPOnly = false) = 0;
// Zoom the current page by flZoom ( from 0.0 to 2.0, so to zoom to 120% use 1.2 ), zooming around point X,Y in the page (use 0,0 if you don't care) // Zoom the current page by flZoom ( from 0.0 to 2.0, so to zoom to 120% use 1.2 ), zooming around point X,Y in the page (use 0,0 if you don't care)
virtual void SetPageScaleFactor( HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY ) = 0; virtual void SetPageScaleFactor(HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY) = 0;
// Enable/disable low-resource background mode, where javascript and repaint timers are throttled, resources are // Enable/disable low-resource background mode, where javascript and repaint timers are throttled, resources are
// more aggressively purged from memory, and audio/video elements are paused. When background mode is enabled, // more aggressively purged from memory, and audio/video elements are paused. When background mode is enabled,
// all HTML5 video and audio objects will execute ".pause()" and gain the property "._steam_background_paused = 1". // all HTML5 video and audio objects will execute ".pause()" and gain the property "._steam_background_paused = 1".
// When background mode is disabled, any video or audio objects with that property will resume with ".play()". // When background mode is disabled, any video or audio objects with that property will resume with ".play()".
virtual void SetBackgroundMode( HHTMLBrowser unBrowserHandle, bool bBackgroundMode ) = 0; virtual void SetBackgroundMode(HHTMLBrowser unBrowserHandle, bool bBackgroundMode) = 0;
// Scale the output display space by this factor, this is useful when displaying content on high dpi devices. // Scale the output display space by this factor, this is useful when displaying content on high dpi devices.
// Specifies the ratio between physical and logical pixels. // Specifies the ratio between physical and logical pixels.
virtual void SetDPIScalingFactor( HHTMLBrowser unBrowserHandle, float flDPIScaling ) = 0; virtual void SetDPIScalingFactor(HHTMLBrowser unBrowserHandle, float flDPIScaling) = 0;
// Open HTML/JS developer tools // Open HTML/JS developer tools
virtual void OpenDeveloperTools( HHTMLBrowser unBrowserHandle ) = 0; virtual void OpenDeveloperTools(HHTMLBrowser unBrowserHandle) = 0;
// CALLBACKS // CALLBACKS
// //
// These set of functions are used as responses to callback requests // These set of functions are used as responses to callback requests
// //
// You MUST call this in response to a HTML_StartRequest_t callback // You MUST call this in response to a HTML_StartRequest_t callback
// Set bAllowed to true to allow this navigation, false to cancel it and stay // Set bAllowed to true to allow this navigation, false to cancel it and stay
// on the current page. You can use this feature to limit the valid pages // on the current page. You can use this feature to limit the valid pages
// allowed in your HTML surface. // allowed in your HTML surface.
virtual void AllowStartRequest( HHTMLBrowser unBrowserHandle, bool bAllowed ) = 0; virtual void AllowStartRequest(HHTMLBrowser unBrowserHandle, bool bAllowed) = 0;
// You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback // You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback
// Set bResult to true for the OK option of a confirm, use false otherwise // Set bResult to true for the OK option of a confirm, use false otherwise
virtual void JSDialogResponse( HHTMLBrowser unBrowserHandle, bool bResult ) = 0; virtual void JSDialogResponse(HHTMLBrowser unBrowserHandle, bool bResult) = 0;
// You MUST call this in response to a HTML_FileOpenDialog_t callback // You MUST call this in response to a HTML_FileOpenDialog_t callback
STEAM_IGNOREATTR() STEAM_IGNOREATTR()
virtual void FileLoadDialogResponse( HHTMLBrowser unBrowserHandle, const char **pchSelectedFiles ) = 0; virtual void FileLoadDialogResponse(HHTMLBrowser unBrowserHandle, const char** pchSelectedFiles) = 0;
}; };
#define STEAMHTMLSURFACE_INTERFACE_VERSION "STEAMHTMLSURFACE_INTERFACE_VERSION_005" #define STEAMHTMLSURFACE_INTERFACE_VERSION "STEAMHTMLSURFACE_INTERFACE_VERSION_005"
// Global interface accessor // Global interface accessor
inline ISteamHTMLSurface *SteamHTMLSurface(); inline ISteamHTMLSurface* SteamHTMLSurface();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamHTMLSurface *, SteamHTMLSurface, STEAMHTMLSURFACE_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamHTMLSurface*, SteamHTMLSurface, STEAMHTMLSURFACE_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The browser is ready for use // Purpose: The browser is ready for use
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_BrowserReady_t, k_iSteamHTMLSurfaceCallbacks + 1 ) STEAM_CALLBACK_BEGIN(HTML_BrowserReady_t, k_iSteamHTMLSurfaceCallbacks + 1)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // this browser is now fully created and ready to navigate to pages STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // this browser is now fully created and ready to navigate to pages
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: the browser has a pending paint // Purpose: the browser has a pending paint
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN(HTML_NeedsPaint_t, k_iSteamHTMLSurfaceCallbacks + 2) STEAM_CALLBACK_BEGIN(HTML_NeedsPaint_t, k_iSteamHTMLSurfaceCallbacks + 2)
STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the browser that needs the paint STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the browser that needs the paint
STEAM_CALLBACK_MEMBER(1, const char *, pBGRA ) // a pointer to the B8G8R8A8 data for this surface, valid until SteamAPI_RunCallbacks is next called STEAM_CALLBACK_MEMBER(1, const char*, pBGRA) // a pointer to the B8G8R8A8 data for this surface, valid until SteamAPI_RunCallbacks is next called
STEAM_CALLBACK_MEMBER(2, uint32, unWide) // the total width of the pBGRA texture STEAM_CALLBACK_MEMBER(2, uint32, unWide) // the total width of the pBGRA texture
STEAM_CALLBACK_MEMBER(3, uint32, unTall) // the total height of the pBGRA texture STEAM_CALLBACK_MEMBER(3, uint32, unTall) // the total height of the pBGRA texture
STEAM_CALLBACK_MEMBER(4, uint32, unUpdateX) // the offset in X for the damage rect for this update STEAM_CALLBACK_MEMBER(4, uint32, unUpdateX) // the offset in X for the damage rect for this update
@ -247,160 +241,144 @@ STEAM_CALLBACK_MEMBER(10, float, flPageScale) // the page scale factor on this p
STEAM_CALLBACK_MEMBER(11, uint32, unPageSerial) // incremented on each new page load, you can use this to reject draws while navigating to new pages STEAM_CALLBACK_MEMBER(11, uint32, unPageSerial) // incremented on each new page load, you can use this to reject draws while navigating to new pages
STEAM_CALLBACK_END(12) STEAM_CALLBACK_END(12)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The browser wanted to navigate to a new page // Purpose: The browser wanted to navigate to a new page
// NOTE - you MUST call AllowStartRequest in response to this callback // NOTE - you MUST call AllowStartRequest in response to this callback
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN(HTML_StartRequest_t, k_iSteamHTMLSurfaceCallbacks + 3) STEAM_CALLBACK_BEGIN(HTML_StartRequest_t, k_iSteamHTMLSurfaceCallbacks + 3)
STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface navigating STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface navigating
STEAM_CALLBACK_MEMBER(1, const char *, pchURL) // the url they wish to navigate to STEAM_CALLBACK_MEMBER(1, const char*, pchURL) // the url they wish to navigate to
STEAM_CALLBACK_MEMBER(2, const char *, pchTarget) // the html link target type (i.e _blank, _self, _parent, _top ) STEAM_CALLBACK_MEMBER(2, const char*, pchTarget) // the html link target type (i.e _blank, _self, _parent, _top )
STEAM_CALLBACK_MEMBER(3, const char *, pchPostData ) // any posted data for the request STEAM_CALLBACK_MEMBER(3, const char*, pchPostData) // any posted data for the request
STEAM_CALLBACK_MEMBER(4, bool, bIsRedirect) // true if this was a http/html redirect from the last load request STEAM_CALLBACK_MEMBER(4, bool, bIsRedirect) // true if this was a http/html redirect from the last load request
STEAM_CALLBACK_END(5) STEAM_CALLBACK_END(5)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The browser has been requested to close due to user interaction (usually from a javascript window.close() call) // Purpose: The browser has been requested to close due to user interaction (usually from a javascript window.close() call)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN(HTML_CloseBrowser_t, k_iSteamHTMLSurfaceCallbacks + 4) STEAM_CALLBACK_BEGIN(HTML_CloseBrowser_t, k_iSteamHTMLSurfaceCallbacks + 4)
STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: the browser is navigating to a new url // Purpose: the browser is navigating to a new url
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_URLChanged_t, k_iSteamHTMLSurfaceCallbacks + 5 ) STEAM_CALLBACK_BEGIN(HTML_URLChanged_t, k_iSteamHTMLSurfaceCallbacks + 5)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface navigating STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface navigating
STEAM_CALLBACK_MEMBER( 1, const char *, pchURL ) // the url they wish to navigate to STEAM_CALLBACK_MEMBER(1, const char*, pchURL) // the url they wish to navigate to
STEAM_CALLBACK_MEMBER( 2, const char *, pchPostData ) // any posted data for the request STEAM_CALLBACK_MEMBER(2, const char*, pchPostData) // any posted data for the request
STEAM_CALLBACK_MEMBER( 3, bool, bIsRedirect ) // true if this was a http/html redirect from the last load request STEAM_CALLBACK_MEMBER(3, bool, bIsRedirect) // true if this was a http/html redirect from the last load request
STEAM_CALLBACK_MEMBER( 4, const char *, pchPageTitle ) // the title of the page STEAM_CALLBACK_MEMBER(4, const char*, pchPageTitle) // the title of the page
STEAM_CALLBACK_MEMBER( 5, bool, bNewNavigation ) // true if this was from a fresh tab and not a click on an existing page STEAM_CALLBACK_MEMBER(5, bool, bNewNavigation) // true if this was from a fresh tab and not a click on an existing page
STEAM_CALLBACK_END(6) STEAM_CALLBACK_END(6)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: A page is finished loading // Purpose: A page is finished loading
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_FinishedRequest_t, k_iSteamHTMLSurfaceCallbacks + 6 ) STEAM_CALLBACK_BEGIN(HTML_FinishedRequest_t, k_iSteamHTMLSurfaceCallbacks + 6)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchURL ) // STEAM_CALLBACK_MEMBER(1, const char*, pchURL) //
STEAM_CALLBACK_MEMBER( 2, const char *, pchPageTitle ) // STEAM_CALLBACK_MEMBER(2, const char*, pchPageTitle) //
STEAM_CALLBACK_END(3) STEAM_CALLBACK_END(3)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: a request to load this url in a new tab // Purpose: a request to load this url in a new tab
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_OpenLinkInNewTab_t, k_iSteamHTMLSurfaceCallbacks + 7 ) STEAM_CALLBACK_BEGIN(HTML_OpenLinkInNewTab_t, k_iSteamHTMLSurfaceCallbacks + 7)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchURL ) // STEAM_CALLBACK_MEMBER(1, const char*, pchURL) //
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: the page has a new title now // Purpose: the page has a new title now
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_ChangedTitle_t, k_iSteamHTMLSurfaceCallbacks + 8 ) STEAM_CALLBACK_BEGIN(HTML_ChangedTitle_t, k_iSteamHTMLSurfaceCallbacks + 8)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchTitle ) // STEAM_CALLBACK_MEMBER(1, const char*, pchTitle) //
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: results from a search // Purpose: results from a search
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_SearchResults_t, k_iSteamHTMLSurfaceCallbacks + 9 ) STEAM_CALLBACK_BEGIN(HTML_SearchResults_t, k_iSteamHTMLSurfaceCallbacks + 9)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, uint32, unResults ) // STEAM_CALLBACK_MEMBER(1, uint32, unResults) //
STEAM_CALLBACK_MEMBER( 2, uint32, unCurrentMatch ) // STEAM_CALLBACK_MEMBER(2, uint32, unCurrentMatch) //
STEAM_CALLBACK_END(3) STEAM_CALLBACK_END(3)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: page history status changed on the ability to go backwards and forward // Purpose: page history status changed on the ability to go backwards and forward
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_CanGoBackAndForward_t, k_iSteamHTMLSurfaceCallbacks + 10 ) STEAM_CALLBACK_BEGIN(HTML_CanGoBackAndForward_t, k_iSteamHTMLSurfaceCallbacks + 10)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, bool, bCanGoBack ) // STEAM_CALLBACK_MEMBER(1, bool, bCanGoBack) //
STEAM_CALLBACK_MEMBER( 2, bool, bCanGoForward ) // STEAM_CALLBACK_MEMBER(2, bool, bCanGoForward) //
STEAM_CALLBACK_END(3) STEAM_CALLBACK_END(3)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: details on the visibility and size of the horizontal scrollbar // Purpose: details on the visibility and size of the horizontal scrollbar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_HorizontalScroll_t, k_iSteamHTMLSurfaceCallbacks + 11 ) STEAM_CALLBACK_BEGIN(HTML_HorizontalScroll_t, k_iSteamHTMLSurfaceCallbacks + 11)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, uint32, unScrollMax ) // STEAM_CALLBACK_MEMBER(1, uint32, unScrollMax) //
STEAM_CALLBACK_MEMBER( 2, uint32, unScrollCurrent ) // STEAM_CALLBACK_MEMBER(2, uint32, unScrollCurrent) //
STEAM_CALLBACK_MEMBER( 3, float, flPageScale ) // STEAM_CALLBACK_MEMBER(3, float, flPageScale) //
STEAM_CALLBACK_MEMBER( 4, bool , bVisible ) // STEAM_CALLBACK_MEMBER(4, bool, bVisible) //
STEAM_CALLBACK_MEMBER( 5, uint32, unPageSize ) // STEAM_CALLBACK_MEMBER(5, uint32, unPageSize) //
STEAM_CALLBACK_END(6) STEAM_CALLBACK_END(6)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: details on the visibility and size of the vertical scrollbar // Purpose: details on the visibility and size of the vertical scrollbar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_VerticalScroll_t, k_iSteamHTMLSurfaceCallbacks + 12 ) STEAM_CALLBACK_BEGIN(HTML_VerticalScroll_t, k_iSteamHTMLSurfaceCallbacks + 12)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, uint32, unScrollMax ) // STEAM_CALLBACK_MEMBER(1, uint32, unScrollMax) //
STEAM_CALLBACK_MEMBER( 2, uint32, unScrollCurrent ) // STEAM_CALLBACK_MEMBER(2, uint32, unScrollCurrent) //
STEAM_CALLBACK_MEMBER( 3, float, flPageScale ) // STEAM_CALLBACK_MEMBER(3, float, flPageScale) //
STEAM_CALLBACK_MEMBER( 4, bool, bVisible ) // STEAM_CALLBACK_MEMBER(4, bool, bVisible) //
STEAM_CALLBACK_MEMBER( 5, uint32, unPageSize ) // STEAM_CALLBACK_MEMBER(5, uint32, unPageSize) //
STEAM_CALLBACK_END(6) STEAM_CALLBACK_END(6)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: response to GetLinkAtPosition call // Purpose: response to GetLinkAtPosition call
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_LinkAtPosition_t, k_iSteamHTMLSurfaceCallbacks + 13 ) STEAM_CALLBACK_BEGIN(HTML_LinkAtPosition_t, k_iSteamHTMLSurfaceCallbacks + 13)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, uint32, x ) // NOTE - Not currently set STEAM_CALLBACK_MEMBER(1, uint32, x) // NOTE - Not currently set
STEAM_CALLBACK_MEMBER( 2, uint32, y ) // NOTE - Not currently set STEAM_CALLBACK_MEMBER(2, uint32, y) // NOTE - Not currently set
STEAM_CALLBACK_MEMBER( 3, const char *, pchURL ) // STEAM_CALLBACK_MEMBER(3, const char*, pchURL) //
STEAM_CALLBACK_MEMBER( 4, bool, bInput ) // STEAM_CALLBACK_MEMBER(4, bool, bInput) //
STEAM_CALLBACK_MEMBER( 5, bool, bLiveLink ) // STEAM_CALLBACK_MEMBER(5, bool, bLiveLink) //
STEAM_CALLBACK_END(6) STEAM_CALLBACK_END(6)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: show a Javascript alert dialog, call JSDialogResponse // Purpose: show a Javascript alert dialog, call JSDialogResponse
// when the user dismisses this dialog (or right away to ignore it) // when the user dismisses this dialog (or right away to ignore it)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_JSAlert_t, k_iSteamHTMLSurfaceCallbacks + 14 ) STEAM_CALLBACK_BEGIN(HTML_JSAlert_t, k_iSteamHTMLSurfaceCallbacks + 14)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchMessage ) // STEAM_CALLBACK_MEMBER(1, const char*, pchMessage) //
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: show a Javascript confirmation dialog, call JSDialogResponse // Purpose: show a Javascript confirmation dialog, call JSDialogResponse
// when the user dismisses this dialog (or right away to ignore it) // when the user dismisses this dialog (or right away to ignore it)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_JSConfirm_t, k_iSteamHTMLSurfaceCallbacks + 15 ) STEAM_CALLBACK_BEGIN(HTML_JSConfirm_t, k_iSteamHTMLSurfaceCallbacks + 15)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchMessage ) // STEAM_CALLBACK_MEMBER(1, const char*, pchMessage) //
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: when received show a file open dialog // Purpose: when received show a file open dialog
// then call FileLoadDialogResponse with the file(s) the user selected. // then call FileLoadDialogResponse with the file(s) the user selected.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_FileOpenDialog_t, k_iSteamHTMLSurfaceCallbacks + 16 ) STEAM_CALLBACK_BEGIN(HTML_FileOpenDialog_t, k_iSteamHTMLSurfaceCallbacks + 16)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchTitle ) // STEAM_CALLBACK_MEMBER(1, const char*, pchTitle) //
STEAM_CALLBACK_MEMBER( 2, const char *, pchInitialFile ) // STEAM_CALLBACK_MEMBER(2, const char*, pchInitialFile) //
STEAM_CALLBACK_END(3) STEAM_CALLBACK_END(3)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: a new html window is being created. // Purpose: a new html window is being created.
// //
@ -410,71 +388,63 @@ STEAM_CALLBACK_END(3)
// to give your application the opportunity to call CreateBrowser and set up // to give your application the opportunity to call CreateBrowser and set up
// a new browser in response to the attempted popup, if you wish to do so. // a new browser in response to the attempted popup, if you wish to do so.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_NewWindow_t, k_iSteamHTMLSurfaceCallbacks + 21 ) STEAM_CALLBACK_BEGIN(HTML_NewWindow_t, k_iSteamHTMLSurfaceCallbacks + 21)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the current surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the current surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchURL ) // the page to load STEAM_CALLBACK_MEMBER(1, const char*, pchURL) // the page to load
STEAM_CALLBACK_MEMBER( 2, uint32, unX ) // the x pos into the page to display the popup STEAM_CALLBACK_MEMBER(2, uint32, unX) // the x pos into the page to display the popup
STEAM_CALLBACK_MEMBER( 3, uint32, unY ) // the y pos into the page to display the popup STEAM_CALLBACK_MEMBER(3, uint32, unY) // the y pos into the page to display the popup
STEAM_CALLBACK_MEMBER( 4, uint32, unWide ) // the total width of the pBGRA texture STEAM_CALLBACK_MEMBER(4, uint32, unWide) // the total width of the pBGRA texture
STEAM_CALLBACK_MEMBER( 5, uint32, unTall ) // the total height of the pBGRA texture STEAM_CALLBACK_MEMBER(5, uint32, unTall) // the total height of the pBGRA texture
STEAM_CALLBACK_MEMBER( 6, HHTMLBrowser, unNewWindow_BrowserHandle_IGNORE ) STEAM_CALLBACK_MEMBER(6, HHTMLBrowser, unNewWindow_BrowserHandle_IGNORE)
STEAM_CALLBACK_END(7) STEAM_CALLBACK_END(7)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: change the cursor to display // Purpose: change the cursor to display
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_SetCursor_t, k_iSteamHTMLSurfaceCallbacks + 22 ) STEAM_CALLBACK_BEGIN(HTML_SetCursor_t, k_iSteamHTMLSurfaceCallbacks + 22)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, uint32, eMouseCursor ) // the EMouseCursor to display STEAM_CALLBACK_MEMBER(1, uint32, eMouseCursor) // the EMouseCursor to display
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: informational message from the browser // Purpose: informational message from the browser
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_StatusText_t, k_iSteamHTMLSurfaceCallbacks + 23 ) STEAM_CALLBACK_BEGIN(HTML_StatusText_t, k_iSteamHTMLSurfaceCallbacks + 23)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display STEAM_CALLBACK_MEMBER(1, const char*, pchMsg) // the EMouseCursor to display
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: show a tooltip // Purpose: show a tooltip
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_ShowToolTip_t, k_iSteamHTMLSurfaceCallbacks + 24 ) STEAM_CALLBACK_BEGIN(HTML_ShowToolTip_t, k_iSteamHTMLSurfaceCallbacks + 24)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display STEAM_CALLBACK_MEMBER(1, const char*, pchMsg) // the EMouseCursor to display
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: update the text of an existing tooltip // Purpose: update the text of an existing tooltip
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_UpdateToolTip_t, k_iSteamHTMLSurfaceCallbacks + 25 ) STEAM_CALLBACK_BEGIN(HTML_UpdateToolTip_t, k_iSteamHTMLSurfaceCallbacks + 25)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display STEAM_CALLBACK_MEMBER(1, const char*, pchMsg) // the EMouseCursor to display
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: hide the tooltip you are showing // Purpose: hide the tooltip you are showing
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_HideToolTip_t, k_iSteamHTMLSurfaceCallbacks + 26 ) STEAM_CALLBACK_BEGIN(HTML_HideToolTip_t, k_iSteamHTMLSurfaceCallbacks + 26)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The browser has restarted due to an internal failure, use this new handle value // Purpose: The browser has restarted due to an internal failure, use this new handle value
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
STEAM_CALLBACK_BEGIN( HTML_BrowserRestarted_t, k_iSteamHTMLSurfaceCallbacks + 27 ) STEAM_CALLBACK_BEGIN(HTML_BrowserRestarted_t, k_iSteamHTMLSurfaceCallbacks + 27)
STEAM_CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // this is the new browser handle after the restart STEAM_CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // this is the new browser handle after the restart
STEAM_CALLBACK_MEMBER( 1, HHTMLBrowser, unOldBrowserHandle ) // the handle for the browser before the restart, if your handle was this then switch to using unBrowserHandle for API calls STEAM_CALLBACK_MEMBER(1, HHTMLBrowser, unOldBrowserHandle) // the handle for the browser before the restart, if your handle was this then switch to using unBrowserHandle for API calls
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
#pragma pack(pop)
#pragma pack( pop )
#endif // ISTEAMHTMLSURFACE_H #endif // ISTEAMHTMLSURFACE_H

View File

@ -1,6 +1,6 @@
//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. ======= //====== Copyright © 1996-2009, Valve Corporation, All rights reserved. =======
// //
// Purpose: interface to http client // Purpose: interface to http client
// //
//============================================================================= //=============================================================================
@ -15,205 +15,197 @@
// Handle to a HTTP Request handle // Handle to a HTTP Request handle
typedef uint32 HTTPRequestHandle; typedef uint32 HTTPRequestHandle;
#define INVALID_HTTPREQUEST_HANDLE 0 #define INVALID_HTTPREQUEST_HANDLE 0
typedef uint32 HTTPCookieContainerHandle; typedef uint32 HTTPCookieContainerHandle;
#define INVALID_HTTPCOOKIE_HANDLE 0 #define INVALID_HTTPCOOKIE_HANDLE 0
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: interface to http client // Purpose: interface to http client
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamHTTP class ISteamHTTP {
{
public: public:
// Initializes a new HTTP request, returning a handle to use in further operations on it. Requires
// the method (GET or POST) and the absolute URL for the request. Both http and https are supported,
// so this string must start with http:// or https:// and should look like http://store.steampowered.com/app/250/
// or such.
virtual HTTPRequestHandle CreateHTTPRequest(EHTTPMethod eHTTPRequestMethod, const char* pchAbsoluteURL) = 0;
// Initializes a new HTTP request, returning a handle to use in further operations on it. Requires // Set a context value for the request, which will be returned in the HTTPRequestCompleted_t callback after
// the method (GET or POST) and the absolute URL for the request. Both http and https are supported, // sending the request. This is just so the caller can easily keep track of which callbacks go with which request data.
// so this string must start with http:// or https:// and should look like http://store.steampowered.com/app/250/ virtual bool SetHTTPRequestContextValue(HTTPRequestHandle hRequest, uint64 ulContextValue) = 0;
// or such.
virtual HTTPRequestHandle CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod, const char *pchAbsoluteURL ) = 0;
// Set a context value for the request, which will be returned in the HTTPRequestCompleted_t callback after // Set a timeout in seconds for the HTTP request, must be called prior to sending the request. Default
// sending the request. This is just so the caller can easily keep track of which callbacks go with which request data. // timeout is 60 seconds if you don't call this. Returns false if the handle is invalid, or the request
virtual bool SetHTTPRequestContextValue( HTTPRequestHandle hRequest, uint64 ulContextValue ) = 0; // has already been sent.
virtual bool SetHTTPRequestNetworkActivityTimeout(HTTPRequestHandle hRequest, uint32 unTimeoutSeconds) = 0;
// Set a timeout in seconds for the HTTP request, must be called prior to sending the request. Default // Set a request header value for the request, must be called prior to sending the request. Will
// timeout is 60 seconds if you don't call this. Returns false if the handle is invalid, or the request // return false if the handle is invalid or the request is already sent.
// has already been sent. virtual bool SetHTTPRequestHeaderValue(HTTPRequestHandle hRequest, const char* pchHeaderName, const char* pchHeaderValue) = 0;
virtual bool SetHTTPRequestNetworkActivityTimeout( HTTPRequestHandle hRequest, uint32 unTimeoutSeconds ) = 0;
// Set a request header value for the request, must be called prior to sending the request. Will // Set a GET or POST parameter value on the request, which is set will depend on the EHTTPMethod specified
// return false if the handle is invalid or the request is already sent. // when creating the request. Must be called prior to sending the request. Will return false if the
virtual bool SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, const char *pchHeaderValue ) = 0; // handle is invalid or the request is already sent.
virtual bool SetHTTPRequestGetOrPostParameter(HTTPRequestHandle hRequest, const char* pchParamName, const char* pchParamValue) = 0;
// Set a GET or POST parameter value on the request, which is set will depend on the EHTTPMethod specified // Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on
// when creating the request. Must be called prior to sending the request. Will return false if the // asynchronous response via callback.
// handle is invalid or the request is already sent. //
virtual bool SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest, const char *pchParamName, const char *pchParamValue ) = 0; // Note: If the user is in offline mode in Steam, then this will add a only-if-cached cache-control
// header and only do a local cache lookup rather than sending any actual remote request.
virtual bool SendHTTPRequest(HTTPRequestHandle hRequest, SteamAPICall_t* pCallHandle) = 0;
// Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on // Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on
// asynchronous response via callback. // asynchronous response via callback for completion, and listen for HTTPRequestHeadersReceived_t and
// // HTTPRequestDataReceived_t callbacks while streaming.
// Note: If the user is in offline mode in Steam, then this will add a only-if-cached cache-control virtual bool SendHTTPRequestAndStreamResponse(HTTPRequestHandle hRequest, SteamAPICall_t* pCallHandle) = 0;
// header and only do a local cache lookup rather than sending any actual remote request.
virtual bool SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pCallHandle ) = 0;
// Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on // Defers a request you have sent, the actual HTTP client code may have many requests queued, and this will move
// asynchronous response via callback for completion, and listen for HTTPRequestHeadersReceived_t and // the specified request to the tail of the queue. Returns false on invalid handle, or if the request is not yet sent.
// HTTPRequestDataReceived_t callbacks while streaming. virtual bool DeferHTTPRequest(HTTPRequestHandle hRequest) = 0;
virtual bool SendHTTPRequestAndStreamResponse( HTTPRequestHandle hRequest, SteamAPICall_t *pCallHandle ) = 0;
// Defers a request you have sent, the actual HTTP client code may have many requests queued, and this will move // Prioritizes a request you have sent, the actual HTTP client code may have many requests queued, and this will move
// the specified request to the tail of the queue. Returns false on invalid handle, or if the request is not yet sent. // the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent.
virtual bool DeferHTTPRequest( HTTPRequestHandle hRequest ) = 0; virtual bool PrioritizeHTTPRequest(HTTPRequestHandle hRequest) = 0;
// Prioritizes a request you have sent, the actual HTTP client code may have many requests queued, and this will move // Checks if a response header is present in a HTTP response given a handle from HTTPRequestCompleted_t, also
// the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent. // returns the size of the header value if present so the caller and allocate a correctly sized buffer for
virtual bool PrioritizeHTTPRequest( HTTPRequestHandle hRequest ) = 0; // GetHTTPResponseHeaderValue.
virtual bool GetHTTPResponseHeaderSize(HTTPRequestHandle hRequest, const char* pchHeaderName, uint32* unResponseHeaderSize) = 0;
// Checks if a response header is present in a HTTP response given a handle from HTTPRequestCompleted_t, also // Gets header values from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the
// returns the size of the header value if present so the caller and allocate a correctly sized buffer for // header is not present or if your buffer is too small to contain it's value. You should first call
// GetHTTPResponseHeaderValue. // BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed.
virtual bool GetHTTPResponseHeaderSize( HTTPRequestHandle hRequest, const char *pchHeaderName, uint32 *unResponseHeaderSize ) = 0; virtual bool GetHTTPResponseHeaderValue(HTTPRequestHandle hRequest, const char* pchHeaderName, uint8* pHeaderValueBuffer, uint32 unBufferSize) = 0;
// Gets header values from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the // Gets the size of the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the
// header is not present or if your buffer is too small to contain it's value. You should first call // handle is invalid.
// BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed. virtual bool GetHTTPResponseBodySize(HTTPRequestHandle hRequest, uint32* unBodySize) = 0;
virtual bool GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, uint8 *pHeaderValueBuffer, uint32 unBufferSize ) = 0;
// Gets the size of the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the // Gets the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the
// handle is invalid. // handle is invalid or is to a streaming response, or if the provided buffer is not the correct size. Use BGetHTTPResponseBodySize first to find out
virtual bool GetHTTPResponseBodySize( HTTPRequestHandle hRequest, uint32 *unBodySize ) = 0; // the correct buffer size to use.
virtual bool GetHTTPResponseBodyData(HTTPRequestHandle hRequest, uint8* pBodyDataBuffer, uint32 unBufferSize) = 0;
// Gets the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the // Gets the body data from a streaming HTTP response given a handle from HTTPRequestDataReceived_t. Will return false if the
// handle is invalid or is to a streaming response, or if the provided buffer is not the correct size. Use BGetHTTPResponseBodySize first to find out // handle is invalid or is to a non-streaming response (meaning it wasn't sent with SendHTTPRequestAndStreamResponse), or if the buffer size and offset
// the correct buffer size to use. // do not match the size and offset sent in HTTPRequestDataReceived_t.
virtual bool GetHTTPResponseBodyData( HTTPRequestHandle hRequest, uint8 *pBodyDataBuffer, uint32 unBufferSize ) = 0; virtual bool GetHTTPStreamingResponseBodyData(HTTPRequestHandle hRequest, uint32 cOffset, uint8* pBodyDataBuffer, uint32 unBufferSize) = 0;
// Gets the body data from a streaming HTTP response given a handle from HTTPRequestDataReceived_t. Will return false if the // Releases an HTTP response handle, should always be called to free resources after receiving a HTTPRequestCompleted_t
// handle is invalid or is to a non-streaming response (meaning it wasn't sent with SendHTTPRequestAndStreamResponse), or if the buffer size and offset // callback and finishing using the response.
// do not match the size and offset sent in HTTPRequestDataReceived_t. virtual bool ReleaseHTTPRequest(HTTPRequestHandle hRequest) = 0;
virtual bool GetHTTPStreamingResponseBodyData( HTTPRequestHandle hRequest, uint32 cOffset, uint8 *pBodyDataBuffer, uint32 unBufferSize ) = 0;
// Releases an HTTP response handle, should always be called to free resources after receiving a HTTPRequestCompleted_t // Gets progress on downloading the body for the request. This will be zero unless a response header has already been
// callback and finishing using the response. // received which included a content-length field. For responses that contain no content-length it will report
virtual bool ReleaseHTTPRequest( HTTPRequestHandle hRequest ) = 0; // zero for the duration of the request as the size is unknown until the connection closes.
virtual bool GetHTTPDownloadProgressPct(HTTPRequestHandle hRequest, float* pflPercentOut) = 0;
// Gets progress on downloading the body for the request. This will be zero unless a response header has already been // Sets the body for an HTTP Post request. Will fail and return false on a GET request, and will fail if POST params
// received which included a content-length field. For responses that contain no content-length it will report // have already been set for the request. Setting this raw body makes it the only contents for the post, the pchContentType
// zero for the duration of the request as the size is unknown until the connection closes. // parameter will set the content-type header for the request so the server may know how to interpret the body.
virtual bool GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest, float *pflPercentOut ) = 0; virtual bool SetHTTPRequestRawPostBody(HTTPRequestHandle hRequest, const char* pchContentType, uint8* pubBody, uint32 unBodyLen) = 0;
// Sets the body for an HTTP Post request. Will fail and return false on a GET request, and will fail if POST params // Creates a cookie container handle which you must later free with ReleaseCookieContainer(). If bAllowResponsesToModify=true
// have already been set for the request. Setting this raw body makes it the only contents for the post, the pchContentType // than any response to your requests using this cookie container may add new cookies which may be transmitted with
// parameter will set the content-type header for the request so the server may know how to interpret the body. // future requests. If bAllowResponsesToModify=false than only cookies you explicitly set will be sent. This API is just for
virtual bool SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest, const char *pchContentType, uint8 *pubBody, uint32 unBodyLen ) = 0; // during process lifetime, after steam restarts no cookies are persisted and you have no way to access the cookie container across
// repeat executions of your process.
virtual HTTPCookieContainerHandle CreateCookieContainer(bool bAllowResponsesToModify) = 0;
// Creates a cookie container handle which you must later free with ReleaseCookieContainer(). If bAllowResponsesToModify=true // Release a cookie container you are finished using, freeing it's memory
// than any response to your requests using this cookie container may add new cookies which may be transmitted with virtual bool ReleaseCookieContainer(HTTPCookieContainerHandle hCookieContainer) = 0;
// future requests. If bAllowResponsesToModify=false than only cookies you explicitly set will be sent. This API is just for
// during process lifetime, after steam restarts no cookies are persisted and you have no way to access the cookie container across
// repeat executions of your process.
virtual HTTPCookieContainerHandle CreateCookieContainer( bool bAllowResponsesToModify ) = 0;
// Release a cookie container you are finished using, freeing it's memory // Adds a cookie to the specified cookie container that will be used with future requests.
virtual bool ReleaseCookieContainer( HTTPCookieContainerHandle hCookieContainer ) = 0; virtual bool SetCookie(HTTPCookieContainerHandle hCookieContainer, const char* pchHost, const char* pchUrl, const char* pchCookie) = 0;
// Adds a cookie to the specified cookie container that will be used with future requests. // Set the cookie container to use for a HTTP request
virtual bool SetCookie( HTTPCookieContainerHandle hCookieContainer, const char *pchHost, const char *pchUrl, const char *pchCookie ) = 0; virtual bool SetHTTPRequestCookieContainer(HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer) = 0;
// Set the cookie container to use for a HTTP request // Set the extra user agent info for a request, this doesn't clobber the normal user agent, it just adds the extra info on the end
virtual bool SetHTTPRequestCookieContainer( HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer ) = 0; virtual bool SetHTTPRequestUserAgentInfo(HTTPRequestHandle hRequest, const char* pchUserAgentInfo) = 0;
// Set the extra user agent info for a request, this doesn't clobber the normal user agent, it just adds the extra info on the end // Disable or re-enable verification of SSL/TLS certificates.
virtual bool SetHTTPRequestUserAgentInfo( HTTPRequestHandle hRequest, const char *pchUserAgentInfo ) = 0; // By default, certificates are checked for all HTTPS requests.
virtual bool SetHTTPRequestRequiresVerifiedCertificate(HTTPRequestHandle hRequest, bool bRequireVerifiedCertificate) = 0;
// Disable or re-enable verification of SSL/TLS certificates. // Set an absolute timeout on the HTTP request, this is just a total time timeout different than the network activity timeout
// By default, certificates are checked for all HTTPS requests. // which can bump everytime we get more data
virtual bool SetHTTPRequestRequiresVerifiedCertificate( HTTPRequestHandle hRequest, bool bRequireVerifiedCertificate ) = 0; virtual bool SetHTTPRequestAbsoluteTimeoutMS(HTTPRequestHandle hRequest, uint32 unMilliseconds) = 0;
// Set an absolute timeout on the HTTP request, this is just a total time timeout different than the network activity timeout // Check if the reason the request failed was because we timed it out (rather than some harder failure)
// which can bump everytime we get more data virtual bool GetHTTPRequestWasTimedOut(HTTPRequestHandle hRequest, bool* pbWasTimedOut) = 0;
virtual bool SetHTTPRequestAbsoluteTimeoutMS( HTTPRequestHandle hRequest, uint32 unMilliseconds ) = 0;
// Check if the reason the request failed was because we timed it out (rather than some harder failure)
virtual bool GetHTTPRequestWasTimedOut( HTTPRequestHandle hRequest, bool *pbWasTimedOut ) = 0;
}; };
#define STEAMHTTP_INTERFACE_VERSION "STEAMHTTP_INTERFACE_VERSION003" #define STEAMHTTP_INTERFACE_VERSION "STEAMHTTP_INTERFACE_VERSION003"
// Global interface accessor // Global interface accessor
inline ISteamHTTP *SteamHTTP(); inline ISteamHTTP* SteamHTTP();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamHTTP *, SteamHTTP, STEAMHTTP_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamHTTP*, SteamHTTP, STEAMHTTP_INTERFACE_VERSION);
// Global accessor for the gameserver client // Global accessor for the gameserver client
inline ISteamHTTP *SteamGameServerHTTP(); inline ISteamHTTP* SteamGameServerHTTP();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamHTTP *, SteamGameServerHTTP, STEAMHTTP_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamHTTP*, SteamGameServerHTTP, STEAMHTTP_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
struct HTTPRequestCompleted_t struct HTTPRequestCompleted_t {
{ enum { k_iCallback = k_iClientHTTPCallbacks + 1 };
enum { k_iCallback = k_iClientHTTPCallbacks + 1 };
// Handle value for the request that has completed. // Handle value for the request that has completed.
HTTPRequestHandle m_hRequest; HTTPRequestHandle m_hRequest;
// Context value that the user defined on the request that this callback is associated with, 0 if // Context value that the user defined on the request that this callback is associated with, 0 if
// no context value was set. // no context value was set.
uint64 m_ulContextValue; uint64 m_ulContextValue;
// This will be true if we actually got any sort of response from the server (even an error). // This will be true if we actually got any sort of response from the server (even an error).
// It will be false if we failed due to an internal error or client side network failure. // It will be false if we failed due to an internal error or client side network failure.
bool m_bRequestSuccessful; bool m_bRequestSuccessful;
// Will be the HTTP status code value returned by the server, k_EHTTPStatusCode200OK is the normal // Will be the HTTP status code value returned by the server, k_EHTTPStatusCode200OK is the normal
// OK response, if you get something else you probably need to treat it as a failure. // OK response, if you get something else you probably need to treat it as a failure.
EHTTPStatusCode m_eStatusCode; EHTTPStatusCode m_eStatusCode;
uint32 m_unBodySize; // Same as GetHTTPResponseBodySize() uint32 m_unBodySize; // Same as GetHTTPResponseBodySize()
}; };
struct HTTPRequestHeadersReceived_t {
enum { k_iCallback = k_iClientHTTPCallbacks + 2 };
struct HTTPRequestHeadersReceived_t // Handle value for the request that has received headers.
{ HTTPRequestHandle m_hRequest;
enum { k_iCallback = k_iClientHTTPCallbacks + 2 };
// Handle value for the request that has received headers. // Context value that the user defined on the request that this callback is associated with, 0 if
HTTPRequestHandle m_hRequest; // no context value was set.
uint64 m_ulContextValue;
// Context value that the user defined on the request that this callback is associated with, 0 if
// no context value was set.
uint64 m_ulContextValue;
}; };
struct HTTPRequestDataReceived_t struct HTTPRequestDataReceived_t {
{ enum { k_iCallback = k_iClientHTTPCallbacks + 3 };
enum { k_iCallback = k_iClientHTTPCallbacks + 3 };
// Handle value for the request that has received data. // Handle value for the request that has received data.
HTTPRequestHandle m_hRequest; HTTPRequestHandle m_hRequest;
// Context value that the user defined on the request that this callback is associated with, 0 if // Context value that the user defined on the request that this callback is associated with, 0 if
// no context value was set. // no context value was set.
uint64 m_ulContextValue; uint64 m_ulContextValue;
// Offset to provide to GetHTTPStreamingResponseBodyData to get this chunk of data
uint32 m_cOffset;
// Offset to provide to GetHTTPStreamingResponseBodyData to get this chunk of data // Size to provide to GetHTTPStreamingResponseBodyData to get this chunk of data
uint32 m_cOffset; uint32 m_cBytesReceived;
// Size to provide to GetHTTPStreamingResponseBodyData to get this chunk of data
uint32 m_cBytesReceived;
}; };
#pragma pack(pop)
#pragma pack( pop )
#endif // ISTEAMHTTP_H #endif // ISTEAMHTTP_H

File diff suppressed because it is too large Load Diff

View File

@ -13,15 +13,14 @@
#include "steam_api_common.h" #include "steam_api_common.h"
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
// Every individual instance of an item has a globally-unique ItemInstanceID. // Every individual instance of an item has a globally-unique ItemInstanceID.
// This ID is unique to the combination of (player, specific item instance) // This ID is unique to the combination of (player, specific item instance)
// and will not be transferred to another player or re-used for another item. // and will not be transferred to another player or re-used for another item.
@ -35,26 +34,23 @@ static const SteamItemInstanceID_t k_SteamItemInstanceIDInvalid = (SteamItemInst
// reserved for internal Steam use. // reserved for internal Steam use.
typedef int32 SteamItemDef_t; typedef int32 SteamItemDef_t;
enum ESteamItemFlags {
// Item status flags - these flags are permanently attached to specific item instances
k_ESteamItemNoTrade = 1 << 0, // This item is account-locked and cannot be traded or given away.
enum ESteamItemFlags // Action confirmation flags - these flags are set one time only, as part of a result set
{ k_ESteamItemRemoved = 1 << 8, // The item has been destroyed, traded away, expired, or otherwise invalidated
// Item status flags - these flags are permanently attached to specific item instances k_ESteamItemConsumed = 1 << 9, // The item quantity has been decreased by 1 via ConsumeItem API.
k_ESteamItemNoTrade = 1 << 0, // This item is account-locked and cannot be traded or given away.
// Action confirmation flags - these flags are set one time only, as part of a result set // All other flag bits are currently reserved for internal Steam use at this time.
k_ESteamItemRemoved = 1 << 8, // The item has been destroyed, traded away, expired, or otherwise invalidated // Do not assume anything about the state of other flags which are not defined here.
k_ESteamItemConsumed = 1 << 9, // The item quantity has been decreased by 1 via ConsumeItem API.
// All other flag bits are currently reserved for internal Steam use at this time.
// Do not assume anything about the state of other flags which are not defined here.
}; };
struct SteamItemDetails_t struct SteamItemDetails_t {
{ SteamItemInstanceID_t m_itemId;
SteamItemInstanceID_t m_itemId; SteamItemDef_t m_iDefinition;
SteamItemDef_t m_iDefinition; uint16 m_unQuantity;
uint16 m_unQuantity; uint16 m_unFlags; // see ESteamItemFlags
uint16 m_unFlags; // see ESteamItemFlags
}; };
typedef int32 SteamInventoryResult_t; typedef int32 SteamInventoryResult_t;
@ -67,330 +63,325 @@ const SteamInventoryUpdateHandle_t k_SteamInventoryUpdateHandleInvalid = 0xfffff
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Steam Inventory query and manipulation API // Purpose: Steam Inventory query and manipulation API
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamInventory class ISteamInventory {
{
public: public:
// INVENTORY ASYNC RESULT MANAGEMENT
//
// Asynchronous inventory queries always output a result handle which can be used with
// GetResultStatus, GetResultItems, etc. A SteamInventoryResultReady_t callback will
// be triggered when the asynchronous result becomes ready (or fails).
//
// INVENTORY ASYNC RESULT MANAGEMENT // Find out the status of an asynchronous inventory result handle. Possible values:
// // k_EResultPending - still in progress
// Asynchronous inventory queries always output a result handle which can be used with // k_EResultOK - done, result ready
// GetResultStatus, GetResultItems, etc. A SteamInventoryResultReady_t callback will // k_EResultExpired - done, result ready, maybe out of date (see DeserializeResult)
// be triggered when the asynchronous result becomes ready (or fails). // k_EResultInvalidParam - ERROR: invalid API call parameters
// // k_EResultServiceUnavailable - ERROR: service temporarily down, you may retry later
// k_EResultLimitExceeded - ERROR: operation would exceed per-user inventory limits
// k_EResultFail - ERROR: unknown / generic error
STEAM_METHOD_DESC(Find out the status of an asynchronous inventory result handle.)
virtual EResult GetResultStatus(SteamInventoryResult_t resultHandle) = 0;
// Find out the status of an asynchronous inventory result handle. Possible values: // Copies the contents of a result set into a flat array. The specific
// k_EResultPending - still in progress // contents of the result set depend on which query which was used.
// k_EResultOK - done, result ready STEAM_METHOD_DESC(Copies the contents of a result set into a flat array.The specific contents of the result set depend on which query which was used.)
// k_EResultExpired - done, result ready, maybe out of date (see DeserializeResult) virtual bool GetResultItems(SteamInventoryResult_t resultHandle,
// k_EResultInvalidParam - ERROR: invalid API call parameters STEAM_OUT_ARRAY_COUNT(punOutItemsArraySize, Output array) SteamItemDetails_t* pOutItemsArray,
// k_EResultServiceUnavailable - ERROR: service temporarily down, you may retry later uint32* punOutItemsArraySize)
// k_EResultLimitExceeded - ERROR: operation would exceed per-user inventory limits = 0;
// k_EResultFail - ERROR: unknown / generic error
STEAM_METHOD_DESC(Find out the status of an asynchronous inventory result handle.)
virtual EResult GetResultStatus( SteamInventoryResult_t resultHandle ) = 0;
// Copies the contents of a result set into a flat array. The specific // In combination with GetResultItems, you can use GetResultItemProperty to retrieve
// contents of the result set depend on which query which was used. // dynamic string properties for a given item returned in the result set.
STEAM_METHOD_DESC(Copies the contents of a result set into a flat array. The specific contents of the result set depend on which query which was used.) //
virtual bool GetResultItems( SteamInventoryResult_t resultHandle, // Property names are always composed of ASCII letters, numbers, and/or underscores.
STEAM_OUT_ARRAY_COUNT( punOutItemsArraySize,Output array) SteamItemDetails_t *pOutItemsArray, //
uint32 *punOutItemsArraySize ) = 0; // Pass a NULL pointer for pchPropertyName to get a comma - separated list of available
// property names.
//
// If pchValueBuffer is NULL, *punValueBufferSize will contain the
// suggested buffer size. Otherwise it will be the number of bytes actually copied
// to pchValueBuffer. If the results do not fit in the given buffer, partial
// results may be copied.
virtual bool GetResultItemProperty(SteamInventoryResult_t resultHandle,
uint32 unItemIndex,
const char* pchPropertyName,
STEAM_OUT_STRING_COUNT(punValueBufferSizeOut) char* pchValueBuffer, uint32* punValueBufferSizeOut)
= 0;
// In combination with GetResultItems, you can use GetResultItemProperty to retrieve // Returns the server time at which the result was generated. Compare against
// dynamic string properties for a given item returned in the result set. // the value of IClientUtils::GetServerRealTime() to determine age.
// STEAM_METHOD_DESC(Returns the server time at which the result was generated.Compare against the value of IClientUtils::GetServerRealTime() to determine age.)
// Property names are always composed of ASCII letters, numbers, and/or underscores. virtual uint32 GetResultTimestamp(SteamInventoryResult_t resultHandle) = 0;
//
// Pass a NULL pointer for pchPropertyName to get a comma - separated list of available
// property names.
//
// If pchValueBuffer is NULL, *punValueBufferSize will contain the
// suggested buffer size. Otherwise it will be the number of bytes actually copied
// to pchValueBuffer. If the results do not fit in the given buffer, partial
// results may be copied.
virtual bool GetResultItemProperty( SteamInventoryResult_t resultHandle,
uint32 unItemIndex,
const char *pchPropertyName,
STEAM_OUT_STRING_COUNT( punValueBufferSizeOut ) char *pchValueBuffer, uint32 *punValueBufferSizeOut ) = 0;
// Returns the server time at which the result was generated. Compare against // Returns true if the result belongs to the target steam ID, false if the
// the value of IClientUtils::GetServerRealTime() to determine age. // result does not. This is important when using DeserializeResult, to verify
STEAM_METHOD_DESC(Returns the server time at which the result was generated. Compare against the value of IClientUtils::GetServerRealTime() to determine age.) // that a remote player is not pretending to have a different user's inventory.
virtual uint32 GetResultTimestamp( SteamInventoryResult_t resultHandle ) = 0; STEAM_METHOD_DESC(Returns true if the result belongs to the target steam ID or false if the result does not .This is important when using DeserializeResult to verify that a remote player is not pretending to have a different users inventory.)
virtual bool CheckResultSteamID(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected) = 0;
// Returns true if the result belongs to the target steam ID, false if the // Destroys a result handle and frees all associated memory.
// result does not. This is important when using DeserializeResult, to verify STEAM_METHOD_DESC(Destroys a result handle and frees all associated memory.)
// that a remote player is not pretending to have a different user's inventory. virtual void DestroyResult(SteamInventoryResult_t resultHandle) = 0;
STEAM_METHOD_DESC(Returns true if the result belongs to the target steam ID or false if the result does not. This is important when using DeserializeResult to verify that a remote player is not pretending to have a different users inventory.)
virtual bool CheckResultSteamID( SteamInventoryResult_t resultHandle, CSteamID steamIDExpected ) = 0;
// Destroys a result handle and frees all associated memory. // INVENTORY ASYNC QUERY
STEAM_METHOD_DESC(Destroys a result handle and frees all associated memory.) //
virtual void DestroyResult( SteamInventoryResult_t resultHandle ) = 0;
// Captures the entire state of the current user's Steam inventory.
// You must call DestroyResult on this handle when you are done with it.
// Returns false and sets *pResultHandle to zero if inventory is unavailable.
// Note: calls to this function are subject to rate limits and may return
// cached results if called too frequently. It is suggested that you call
// this function only when you are about to display the user's full inventory,
// or if you expect that the inventory may have changed.
STEAM_METHOD_DESC(Captures the entire state of the current users Steam inventory.)
virtual bool GetAllItems(SteamInventoryResult_t* pResultHandle) = 0;
// INVENTORY ASYNC QUERY // Captures the state of a subset of the current user's Steam inventory,
// // identified by an array of item instance IDs. The results from this call
// can be serialized and passed to other players to "prove" that the current
// user owns specific items, without exposing the user's entire inventory.
// For example, you could call GetItemsByID with the IDs of the user's
// currently equipped cosmetic items and serialize this to a buffer, and
// then transmit this buffer to other players upon joining a game.
STEAM_METHOD_DESC(Captures the state of a subset of the current users Steam inventory identified by an array of item instance IDs.)
virtual bool GetItemsByID(SteamInventoryResult_t* pResultHandle, STEAM_ARRAY_COUNT(unCountInstanceIDs) const SteamItemInstanceID_t* pInstanceIDs, uint32 unCountInstanceIDs) = 0;
// Captures the entire state of the current user's Steam inventory. // RESULT SERIALIZATION AND AUTHENTICATION
// You must call DestroyResult on this handle when you are done with it. //
// Returns false and sets *pResultHandle to zero if inventory is unavailable. // Serialized result sets contain a short signature which can't be forged
// Note: calls to this function are subject to rate limits and may return // or replayed across different game sessions. A result set can be serialized
// cached results if called too frequently. It is suggested that you call // on the local client, transmitted to other players via your game networking,
// this function only when you are about to display the user's full inventory, // and deserialized by the remote players. This is a secure way of preventing
// or if you expect that the inventory may have changed. // hackers from lying about posessing rare/high-value items.
STEAM_METHOD_DESC(Captures the entire state of the current users Steam inventory.)
virtual bool GetAllItems( SteamInventoryResult_t *pResultHandle ) = 0;
// Serializes a result set with signature bytes to an output buffer. Pass
// NULL as an output buffer to get the required size via punOutBufferSize.
// The size of a serialized result depends on the number items which are being
// serialized. When securely transmitting items to other players, it is
// recommended to use "GetItemsByID" first to create a minimal result set.
// Results have a built-in timestamp which will be considered "expired" after
// an hour has elapsed. See DeserializeResult for expiration handling.
virtual bool SerializeResult(SteamInventoryResult_t resultHandle, STEAM_OUT_BUFFER_COUNT(punOutBufferSize) void* pOutBuffer, uint32* punOutBufferSize) = 0;
// Captures the state of a subset of the current user's Steam inventory, // Deserializes a result set and verifies the signature bytes. Returns false
// identified by an array of item instance IDs. The results from this call // if bRequireFullOnlineVerify is set but Steam is running in Offline mode.
// can be serialized and passed to other players to "prove" that the current // Otherwise returns true and then delivers error codes via GetResultStatus.
// user owns specific items, without exposing the user's entire inventory. //
// For example, you could call GetItemsByID with the IDs of the user's // The bRESERVED_MUST_BE_FALSE flag is reserved for future use and should not
// currently equipped cosmetic items and serialize this to a buffer, and // be set to true by your game at this time.
// then transmit this buffer to other players upon joining a game. //
STEAM_METHOD_DESC(Captures the state of a subset of the current users Steam inventory identified by an array of item instance IDs.) // DeserializeResult has a potential soft-failure mode where the handle status
virtual bool GetItemsByID( SteamInventoryResult_t *pResultHandle, STEAM_ARRAY_COUNT( unCountInstanceIDs ) const SteamItemInstanceID_t *pInstanceIDs, uint32 unCountInstanceIDs ) = 0; // is set to k_EResultExpired. GetResultItems() still succeeds in this mode.
// The "expired" result could indicate that the data may be out of date - not
// just due to timed expiration (one hour), but also because one of the items
// in the result set may have been traded or consumed since the result set was
// generated. You could compare the timestamp from GetResultTimestamp() to
// ISteamUtils::GetServerRealTime() to determine how old the data is. You could
// simply ignore the "expired" result code and continue as normal, or you
// could challenge the player with expired data to send an updated result set.
virtual bool DeserializeResult(SteamInventoryResult_t* pOutResultHandle, STEAM_BUFFER_COUNT(punOutBufferSize) const void* pBuffer, uint32 unBufferSize, bool bRESERVED_MUST_BE_FALSE = false) = 0;
// INVENTORY ASYNC MODIFICATION
//
// RESULT SERIALIZATION AND AUTHENTICATION // GenerateItems() creates one or more items and then generates a SteamInventoryCallback_t
// // notification with a matching nCallbackContext parameter. This API is only intended
// Serialized result sets contain a short signature which can't be forged // for prototyping - it is only usable by Steam accounts that belong to the publisher group
// or replayed across different game sessions. A result set can be serialized // for your game.
// on the local client, transmitted to other players via your game networking, // If punArrayQuantity is not NULL, it should be the same length as pArrayItems and should
// and deserialized by the remote players. This is a secure way of preventing // describe the quantity of each item to generate.
// hackers from lying about posessing rare/high-value items. virtual bool GenerateItems(SteamInventoryResult_t* pResultHandle, STEAM_ARRAY_COUNT(unArrayLength) const SteamItemDef_t* pArrayItemDefs, STEAM_ARRAY_COUNT(unArrayLength) const uint32* punArrayQuantity, uint32 unArrayLength) = 0;
// Serializes a result set with signature bytes to an output buffer. Pass // GrantPromoItems() checks the list of promotional items for which the user may be eligible
// NULL as an output buffer to get the required size via punOutBufferSize. // and grants the items (one time only). On success, the result set will include items which
// The size of a serialized result depends on the number items which are being // were granted, if any. If no items were granted because the user isn't eligible for any
// serialized. When securely transmitting items to other players, it is // promotions, this is still considered a success.
// recommended to use "GetItemsByID" first to create a minimal result set. STEAM_METHOD_DESC(GrantPromoItems() checks the list of promotional items for which the user may be eligible and grants the items (one time only).)
// Results have a built-in timestamp which will be considered "expired" after virtual bool GrantPromoItems(SteamInventoryResult_t* pResultHandle) = 0;
// an hour has elapsed. See DeserializeResult for expiration handling.
virtual bool SerializeResult( SteamInventoryResult_t resultHandle, STEAM_OUT_BUFFER_COUNT(punOutBufferSize) void *pOutBuffer, uint32 *punOutBufferSize ) = 0;
// Deserializes a result set and verifies the signature bytes. Returns false // AddPromoItem() / AddPromoItems() are restricted versions of GrantPromoItems(). Instead of
// if bRequireFullOnlineVerify is set but Steam is running in Offline mode. // scanning for all eligible promotional items, the check is restricted to a single item
// Otherwise returns true and then delivers error codes via GetResultStatus. // definition or set of item definitions. This can be useful if your game has custom UI for
// // showing a specific promo item to the user.
// The bRESERVED_MUST_BE_FALSE flag is reserved for future use and should not virtual bool AddPromoItem(SteamInventoryResult_t* pResultHandle, SteamItemDef_t itemDef) = 0;
// be set to true by your game at this time. virtual bool AddPromoItems(SteamInventoryResult_t* pResultHandle, STEAM_ARRAY_COUNT(unArrayLength) const SteamItemDef_t* pArrayItemDefs, uint32 unArrayLength) = 0;
//
// DeserializeResult has a potential soft-failure mode where the handle status
// is set to k_EResultExpired. GetResultItems() still succeeds in this mode.
// The "expired" result could indicate that the data may be out of date - not
// just due to timed expiration (one hour), but also because one of the items
// in the result set may have been traded or consumed since the result set was
// generated. You could compare the timestamp from GetResultTimestamp() to
// ISteamUtils::GetServerRealTime() to determine how old the data is. You could
// simply ignore the "expired" result code and continue as normal, or you
// could challenge the player with expired data to send an updated result set.
virtual bool DeserializeResult( SteamInventoryResult_t *pOutResultHandle, STEAM_BUFFER_COUNT(punOutBufferSize) const void *pBuffer, uint32 unBufferSize, bool bRESERVED_MUST_BE_FALSE = false ) = 0;
// ConsumeItem() removes items from the inventory, permanently. They cannot be recovered.
// INVENTORY ASYNC MODIFICATION // Not for the faint of heart - if your game implements item removal at all, a high-friction
// // UI confirmation process is highly recommended.
STEAM_METHOD_DESC(ConsumeItem() removes items from the inventory permanently.)
// GenerateItems() creates one or more items and then generates a SteamInventoryCallback_t virtual bool ConsumeItem(SteamInventoryResult_t* pResultHandle, SteamItemInstanceID_t itemConsume, uint32 unQuantity) = 0;
// notification with a matching nCallbackContext parameter. This API is only intended
// for prototyping - it is only usable by Steam accounts that belong to the publisher group
// for your game.
// If punArrayQuantity is not NULL, it should be the same length as pArrayItems and should
// describe the quantity of each item to generate.
virtual bool GenerateItems( SteamInventoryResult_t *pResultHandle, STEAM_ARRAY_COUNT(unArrayLength) const SteamItemDef_t *pArrayItemDefs, STEAM_ARRAY_COUNT(unArrayLength) const uint32 *punArrayQuantity, uint32 unArrayLength ) = 0;
// GrantPromoItems() checks the list of promotional items for which the user may be eligible // ExchangeItems() is an atomic combination of item generation and consumption.
// and grants the items (one time only). On success, the result set will include items which // It can be used to implement crafting recipes or transmutations, or items which unpack
// were granted, if any. If no items were granted because the user isn't eligible for any // themselves into other items (e.g., a chest).
// promotions, this is still considered a success. // Exchange recipes are defined in the ItemDef, and explicitly list the required item
STEAM_METHOD_DESC(GrantPromoItems() checks the list of promotional items for which the user may be eligible and grants the items (one time only).) // types and resulting generated type.
virtual bool GrantPromoItems( SteamInventoryResult_t *pResultHandle ) = 0; // Exchange recipes are evaluated atomically by the Inventory Service; if the supplied
// components do not match the recipe, or do not contain sufficient quantity, the
// exchange will fail.
virtual bool ExchangeItems(SteamInventoryResult_t* pResultHandle,
STEAM_ARRAY_COUNT(unArrayGenerateLength) const SteamItemDef_t* pArrayGenerate, STEAM_ARRAY_COUNT(unArrayGenerateLength) const uint32* punArrayGenerateQuantity, uint32 unArrayGenerateLength,
STEAM_ARRAY_COUNT(unArrayDestroyLength) const SteamItemInstanceID_t* pArrayDestroy, STEAM_ARRAY_COUNT(unArrayDestroyLength) const uint32* punArrayDestroyQuantity, uint32 unArrayDestroyLength)
= 0;
// AddPromoItem() / AddPromoItems() are restricted versions of GrantPromoItems(). Instead of // TransferItemQuantity() is intended for use with items which are "stackable" (can have
// scanning for all eligible promotional items, the check is restricted to a single item // quantity greater than one). It can be used to split a stack into two, or to transfer
// definition or set of item definitions. This can be useful if your game has custom UI for // quantity from one stack into another stack of identical items. To split one stack into
// showing a specific promo item to the user. // two, pass k_SteamItemInstanceIDInvalid for itemIdDest and a new item will be generated.
virtual bool AddPromoItem( SteamInventoryResult_t *pResultHandle, SteamItemDef_t itemDef ) = 0; virtual bool TransferItemQuantity(SteamInventoryResult_t* pResultHandle, SteamItemInstanceID_t itemIdSource, uint32 unQuantity, SteamItemInstanceID_t itemIdDest) = 0;
virtual bool AddPromoItems( SteamInventoryResult_t *pResultHandle, STEAM_ARRAY_COUNT(unArrayLength) const SteamItemDef_t *pArrayItemDefs, uint32 unArrayLength ) = 0;
// ConsumeItem() removes items from the inventory, permanently. They cannot be recovered. // TIMED DROPS AND PLAYTIME CREDIT
// Not for the faint of heart - if your game implements item removal at all, a high-friction //
// UI confirmation process is highly recommended.
STEAM_METHOD_DESC(ConsumeItem() removes items from the inventory permanently.)
virtual bool ConsumeItem( SteamInventoryResult_t *pResultHandle, SteamItemInstanceID_t itemConsume, uint32 unQuantity ) = 0;
// ExchangeItems() is an atomic combination of item generation and consumption. // Deprecated. Calling this method is not required for proper playtime accounting.
// It can be used to implement crafting recipes or transmutations, or items which unpack STEAM_METHOD_DESC(Deprecated method.Playtime accounting is performed on the Steam servers.)
// themselves into other items (e.g., a chest). virtual void SendItemDropHeartbeat() = 0;
// Exchange recipes are defined in the ItemDef, and explicitly list the required item
// types and resulting generated type.
// Exchange recipes are evaluated atomically by the Inventory Service; if the supplied
// components do not match the recipe, or do not contain sufficient quantity, the
// exchange will fail.
virtual bool ExchangeItems( SteamInventoryResult_t *pResultHandle,
STEAM_ARRAY_COUNT(unArrayGenerateLength) const SteamItemDef_t *pArrayGenerate, STEAM_ARRAY_COUNT(unArrayGenerateLength) const uint32 *punArrayGenerateQuantity, uint32 unArrayGenerateLength,
STEAM_ARRAY_COUNT(unArrayDestroyLength) const SteamItemInstanceID_t *pArrayDestroy, STEAM_ARRAY_COUNT(unArrayDestroyLength) const uint32 *punArrayDestroyQuantity, uint32 unArrayDestroyLength ) = 0;
// TransferItemQuantity() is intended for use with items which are "stackable" (can have // Playtime credit must be consumed and turned into item drops by your game. Only item
// quantity greater than one). It can be used to split a stack into two, or to transfer // definitions which are marked as "playtime item generators" can be spawned. The call
// quantity from one stack into another stack of identical items. To split one stack into // will return an empty result set if there is not enough playtime credit for a drop.
// two, pass k_SteamItemInstanceIDInvalid for itemIdDest and a new item will be generated. // Your game should call TriggerItemDrop at an appropriate time for the user to receive
virtual bool TransferItemQuantity( SteamInventoryResult_t *pResultHandle, SteamItemInstanceID_t itemIdSource, uint32 unQuantity, SteamItemInstanceID_t itemIdDest ) = 0; // new items, such as between rounds or while the player is dead. Note that players who
// hack their clients could modify the value of "dropListDefinition", so do not use it
// to directly control rarity.
// See your Steamworks configuration to set playtime drop rates for individual itemdefs.
// The client library will suppress too-frequent calls to this method.
STEAM_METHOD_DESC(Playtime credit must be consumed and turned into item drops by your game.)
virtual bool TriggerItemDrop(SteamInventoryResult_t* pResultHandle, SteamItemDef_t dropListDefinition) = 0;
// Deprecated. This method is not supported.
virtual bool TradeItems(SteamInventoryResult_t* pResultHandle, CSteamID steamIDTradePartner,
STEAM_ARRAY_COUNT(nArrayGiveLength) const SteamItemInstanceID_t* pArrayGive, STEAM_ARRAY_COUNT(nArrayGiveLength) const uint32* pArrayGiveQuantity, uint32 nArrayGiveLength,
STEAM_ARRAY_COUNT(nArrayGetLength) const SteamItemInstanceID_t* pArrayGet, STEAM_ARRAY_COUNT(nArrayGetLength) const uint32* pArrayGetQuantity, uint32 nArrayGetLength)
= 0;
// TIMED DROPS AND PLAYTIME CREDIT // ITEM DEFINITIONS
// //
// Item definitions are a mapping of "definition IDs" (integers between 1 and 1000000)
// to a set of string properties. Some of these properties are required to display items
// on the Steam community web site. Other properties can be defined by applications.
// Use of these functions is optional; there is no reason to call LoadItemDefinitions
// if your game hardcodes the numeric definition IDs (eg, purple face mask = 20, blue
// weapon mod = 55) and does not allow for adding new item types without a client patch.
//
// Deprecated. Calling this method is not required for proper playtime accounting. // LoadItemDefinitions triggers the automatic load and refresh of item definitions.
STEAM_METHOD_DESC( Deprecated method. Playtime accounting is performed on the Steam servers. ) // Every time new item definitions are available (eg, from the dynamic addition of new
virtual void SendItemDropHeartbeat() = 0; // item types while players are still in-game), a SteamInventoryDefinitionUpdate_t
// callback will be fired.
STEAM_METHOD_DESC(LoadItemDefinitions triggers the automatic load and refresh of item definitions.)
virtual bool LoadItemDefinitions() = 0;
// Playtime credit must be consumed and turned into item drops by your game. Only item // GetItemDefinitionIDs returns the set of all defined item definition IDs (which are
// definitions which are marked as "playtime item generators" can be spawned. The call // defined via Steamworks configuration, and not necessarily contiguous integers).
// will return an empty result set if there is not enough playtime credit for a drop. // If pItemDefIDs is null, the call will return true and *punItemDefIDsArraySize will
// Your game should call TriggerItemDrop at an appropriate time for the user to receive // contain the total size necessary for a subsequent call. Otherwise, the call will
// new items, such as between rounds or while the player is dead. Note that players who // return false if and only if there is not enough space in the output array.
// hack their clients could modify the value of "dropListDefinition", so do not use it virtual bool GetItemDefinitionIDs(
// to directly control rarity. STEAM_OUT_ARRAY_COUNT(punItemDefIDsArraySize, List of item definition IDs) SteamItemDef_t* pItemDefIDs,
// See your Steamworks configuration to set playtime drop rates for individual itemdefs. STEAM_DESC(Size of array is passed in and actual size used is returned in this param) uint32* punItemDefIDsArraySize)
// The client library will suppress too-frequent calls to this method. = 0;
STEAM_METHOD_DESC(Playtime credit must be consumed and turned into item drops by your game.)
virtual bool TriggerItemDrop( SteamInventoryResult_t *pResultHandle, SteamItemDef_t dropListDefinition ) = 0;
// GetItemDefinitionProperty returns a string property from a given item definition.
// Note that some properties (for example, "name") may be localized and will depend
// on the current Steam language settings (see ISteamApps::GetCurrentGameLanguage).
// Property names are always composed of ASCII letters, numbers, and/or underscores.
// Pass a NULL pointer for pchPropertyName to get a comma - separated list of available
// property names. If pchValueBuffer is NULL, *punValueBufferSize will contain the
// suggested buffer size. Otherwise it will be the number of bytes actually copied
// to pchValueBuffer. If the results do not fit in the given buffer, partial
// results may be copied.
virtual bool GetItemDefinitionProperty(SteamItemDef_t iDefinition, const char* pchPropertyName,
STEAM_OUT_STRING_COUNT(punValueBufferSizeOut) char* pchValueBuffer, uint32* punValueBufferSizeOut)
= 0;
// Deprecated. This method is not supported. // Request the list of "eligible" promo items that can be manually granted to the given
virtual bool TradeItems( SteamInventoryResult_t *pResultHandle, CSteamID steamIDTradePartner, // user. These are promo items of type "manual" that won't be granted automatically.
STEAM_ARRAY_COUNT(nArrayGiveLength) const SteamItemInstanceID_t *pArrayGive, STEAM_ARRAY_COUNT(nArrayGiveLength) const uint32 *pArrayGiveQuantity, uint32 nArrayGiveLength, // An example usage of this is an item that becomes available every week.
STEAM_ARRAY_COUNT(nArrayGetLength) const SteamItemInstanceID_t *pArrayGet, STEAM_ARRAY_COUNT(nArrayGetLength) const uint32 *pArrayGetQuantity, uint32 nArrayGetLength ) = 0; STEAM_CALL_RESULT(SteamInventoryEligiblePromoItemDefIDs_t)
virtual SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID steamID) = 0;
// After handling a SteamInventoryEligiblePromoItemDefIDs_t call result, use this
// function to pull out the list of item definition ids that the user can be
// manually granted via the AddPromoItems() call.
virtual bool GetEligiblePromoItemDefinitionIDs(
CSteamID steamID,
STEAM_OUT_ARRAY_COUNT(punItemDefIDsArraySize, List of item definition IDs) SteamItemDef_t* pItemDefIDs,
STEAM_DESC(Size of array is passed in and actual size used is returned in this param) uint32* punItemDefIDsArraySize)
= 0;
// ITEM DEFINITIONS // Starts the purchase process for the given item definitions. The callback SteamInventoryStartPurchaseResult_t
// // will be posted if Steam was able to initialize the transaction.
// Item definitions are a mapping of "definition IDs" (integers between 1 and 1000000) //
// to a set of string properties. Some of these properties are required to display items // Once the purchase has been authorized and completed by the user, the callback SteamInventoryResultReady_t
// on the Steam community web site. Other properties can be defined by applications. // will be posted.
// Use of these functions is optional; there is no reason to call LoadItemDefinitions STEAM_CALL_RESULT(SteamInventoryStartPurchaseResult_t)
// if your game hardcodes the numeric definition IDs (eg, purple face mask = 20, blue virtual SteamAPICall_t StartPurchase(STEAM_ARRAY_COUNT(unArrayLength) const SteamItemDef_t* pArrayItemDefs, STEAM_ARRAY_COUNT(unArrayLength) const uint32* punArrayQuantity, uint32 unArrayLength) = 0;
// weapon mod = 55) and does not allow for adding new item types without a client patch.
//
// LoadItemDefinitions triggers the automatic load and refresh of item definitions. // Request current prices for all applicable item definitions
// Every time new item definitions are available (eg, from the dynamic addition of new STEAM_CALL_RESULT(SteamInventoryRequestPricesResult_t)
// item types while players are still in-game), a SteamInventoryDefinitionUpdate_t virtual SteamAPICall_t RequestPrices() = 0;
// callback will be fired.
STEAM_METHOD_DESC(LoadItemDefinitions triggers the automatic load and refresh of item definitions.)
virtual bool LoadItemDefinitions() = 0;
// GetItemDefinitionIDs returns the set of all defined item definition IDs (which are // Returns the number of items with prices. Need to call RequestPrices() first.
// defined via Steamworks configuration, and not necessarily contiguous integers). virtual uint32 GetNumItemsWithPrices() = 0;
// If pItemDefIDs is null, the call will return true and *punItemDefIDsArraySize will
// contain the total size necessary for a subsequent call. Otherwise, the call will
// return false if and only if there is not enough space in the output array.
virtual bool GetItemDefinitionIDs(
STEAM_OUT_ARRAY_COUNT(punItemDefIDsArraySize,List of item definition IDs) SteamItemDef_t *pItemDefIDs,
STEAM_DESC(Size of array is passed in and actual size used is returned in this param) uint32 *punItemDefIDsArraySize ) = 0;
// GetItemDefinitionProperty returns a string property from a given item definition. // Returns item definition ids and their prices in the user's local currency.
// Note that some properties (for example, "name") may be localized and will depend // Need to call RequestPrices() first.
// on the current Steam language settings (see ISteamApps::GetCurrentGameLanguage). virtual bool GetItemsWithPrices( STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pArrayItemDefs, Items with prices) SteamItemDef_t *pArrayItemDefs,
// Property names are always composed of ASCII letters, numbers, and/or underscores.
// Pass a NULL pointer for pchPropertyName to get a comma - separated list of available
// property names. If pchValueBuffer is NULL, *punValueBufferSize will contain the
// suggested buffer size. Otherwise it will be the number of bytes actually copied
// to pchValueBuffer. If the results do not fit in the given buffer, partial
// results may be copied.
virtual bool GetItemDefinitionProperty( SteamItemDef_t iDefinition, const char *pchPropertyName,
STEAM_OUT_STRING_COUNT(punValueBufferSizeOut) char *pchValueBuffer, uint32 *punValueBufferSizeOut ) = 0;
// Request the list of "eligible" promo items that can be manually granted to the given
// user. These are promo items of type "manual" that won't be granted automatically.
// An example usage of this is an item that becomes available every week.
STEAM_CALL_RESULT( SteamInventoryEligiblePromoItemDefIDs_t )
virtual SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs( CSteamID steamID ) = 0;
// After handling a SteamInventoryEligiblePromoItemDefIDs_t call result, use this
// function to pull out the list of item definition ids that the user can be
// manually granted via the AddPromoItems() call.
virtual bool GetEligiblePromoItemDefinitionIDs(
CSteamID steamID,
STEAM_OUT_ARRAY_COUNT(punItemDefIDsArraySize,List of item definition IDs) SteamItemDef_t *pItemDefIDs,
STEAM_DESC(Size of array is passed in and actual size used is returned in this param) uint32 *punItemDefIDsArraySize ) = 0;
// Starts the purchase process for the given item definitions. The callback SteamInventoryStartPurchaseResult_t
// will be posted if Steam was able to initialize the transaction.
//
// Once the purchase has been authorized and completed by the user, the callback SteamInventoryResultReady_t
// will be posted.
STEAM_CALL_RESULT( SteamInventoryStartPurchaseResult_t )
virtual SteamAPICall_t StartPurchase( STEAM_ARRAY_COUNT(unArrayLength) const SteamItemDef_t *pArrayItemDefs, STEAM_ARRAY_COUNT(unArrayLength) const uint32 *punArrayQuantity, uint32 unArrayLength ) = 0;
// Request current prices for all applicable item definitions
STEAM_CALL_RESULT( SteamInventoryRequestPricesResult_t )
virtual SteamAPICall_t RequestPrices() = 0;
// Returns the number of items with prices. Need to call RequestPrices() first.
virtual uint32 GetNumItemsWithPrices() = 0;
// Returns item definition ids and their prices in the user's local currency.
// Need to call RequestPrices() first.
virtual bool GetItemsWithPrices( STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pArrayItemDefs, Items with prices) SteamItemDef_t *pArrayItemDefs,
STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pPrices, List of prices for the given item defs) uint64 *pCurrentPrices, STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pPrices, List of prices for the given item defs) uint64 *pCurrentPrices,
STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pPrices, List of prices for the given item defs) uint64 *pBasePrices, STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pPrices, List of prices for the given item defs) uint64 *pBasePrices,
uint32 unArrayLength ) = 0; uint32 unArrayLength ) = 0;
// Retrieves the price for the item definition id // Retrieves the price for the item definition id
// Returns false if there is no price stored for the item definition. // Returns false if there is no price stored for the item definition.
virtual bool GetItemPrice( SteamItemDef_t iDefinition, uint64 *pCurrentPrice, uint64 *pBasePrice ) = 0; virtual bool GetItemPrice(SteamItemDef_t iDefinition, uint64* pCurrentPrice, uint64* pBasePrice) = 0;
// Create a request to update properties on items // Create a request to update properties on items
virtual SteamInventoryUpdateHandle_t StartUpdateProperties() = 0; virtual SteamInventoryUpdateHandle_t StartUpdateProperties() = 0;
// Remove the property on the item // Remove the property on the item
virtual bool RemoveProperty( SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char *pchPropertyName ) = 0; virtual bool RemoveProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char* pchPropertyName) = 0;
// Accessor methods to set properties on items // Accessor methods to set properties on items
STEAM_FLAT_NAME( SetPropertyString ) STEAM_FLAT_NAME(SetPropertyString)
virtual bool SetProperty( SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char *pchPropertyName, const char *pchPropertyValue ) = 0; virtual bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char* pchPropertyName, const char* pchPropertyValue) = 0;
STEAM_FLAT_NAME( SetPropertyBool ) STEAM_FLAT_NAME(SetPropertyBool)
virtual bool SetProperty( SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char *pchPropertyName, bool bValue ) = 0; virtual bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char* pchPropertyName, bool bValue) = 0;
STEAM_FLAT_NAME( SetPropertyInt64 ) STEAM_FLAT_NAME(SetPropertyInt64)
virtual bool SetProperty( SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char *pchPropertyName, int64 nValue ) = 0; virtual bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char* pchPropertyName, int64 nValue) = 0;
STEAM_FLAT_NAME( SetPropertyFloat ) STEAM_FLAT_NAME(SetPropertyFloat)
virtual bool SetProperty( SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char *pchPropertyName, float flValue ) = 0; virtual bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, const char* pchPropertyName, float flValue) = 0;
// Submit the update request by handle // Submit the update request by handle
virtual bool SubmitUpdateProperties( SteamInventoryUpdateHandle_t handle, SteamInventoryResult_t * pResultHandle ) = 0; virtual bool SubmitUpdateProperties(SteamInventoryUpdateHandle_t handle, SteamInventoryResult_t* pResultHandle) = 0;
STEAM_METHOD_DESC(Look up the given token and return a pseudo-Inventory item.) STEAM_METHOD_DESC(Look up the given token and return a pseudo - Inventory item.)
virtual bool InspectItem( SteamInventoryResult_t *pResultHandle, const char *pchItemToken ) = 0; virtual bool InspectItem(SteamInventoryResult_t* pResultHandle, const char* pchItemToken) = 0;
}; };
#define STEAMINVENTORY_INTERFACE_VERSION "STEAMINVENTORY_INTERFACE_V003" #define STEAMINVENTORY_INTERFACE_VERSION "STEAMINVENTORY_INTERFACE_V003"
// Global interface accessor // Global interface accessor
inline ISteamInventory *SteamInventory(); inline ISteamInventory* SteamInventory();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamInventory *, SteamInventory, STEAMINVENTORY_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamInventory*, SteamInventory, STEAMINVENTORY_INTERFACE_VERSION);
// Global accessor for the gameserver client // Global accessor for the gameserver client
inline ISteamInventory *SteamGameServerInventory(); inline ISteamInventory* SteamGameServerInventory();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamInventory *, SteamGameServerInventory, STEAMINVENTORY_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamInventory*, SteamGameServerInventory, STEAMINVENTORY_INTERFACE_VERSION);
// SteamInventoryResultReady_t callbacks are fired whenever asynchronous // SteamInventoryResultReady_t callbacks are fired whenever asynchronous
// results transition from "Pending" to "OK" or an error state. There will // results transition from "Pending" to "OK" or an error state. There will
// always be exactly one callback per handle. // always be exactly one callback per handle.
struct SteamInventoryResultReady_t struct SteamInventoryResultReady_t {
{ enum { k_iCallback = k_iClientInventoryCallbacks + 0 };
enum { k_iCallback = k_iClientInventoryCallbacks + 0 }; SteamInventoryResult_t m_handle;
SteamInventoryResult_t m_handle; EResult m_result;
EResult m_result;
}; };
// SteamInventoryFullUpdate_t callbacks are triggered when GetAllItems // SteamInventoryFullUpdate_t callbacks are triggered when GetAllItems
// successfully returns a result which is newer / fresher than the last // successfully returns a result which is newer / fresher than the last
// known result. (It will not trigger if the inventory hasn't changed, // known result. (It will not trigger if the inventory hasn't changed,
@ -398,51 +389,43 @@ struct SteamInventoryResultReady_t
// the earlier result is already known to be stale/out-of-date.) // the earlier result is already known to be stale/out-of-date.)
// The normal ResultReady callback will still be triggered immediately // The normal ResultReady callback will still be triggered immediately
// afterwards; this is an additional notification for your convenience. // afterwards; this is an additional notification for your convenience.
struct SteamInventoryFullUpdate_t struct SteamInventoryFullUpdate_t {
{ enum { k_iCallback = k_iClientInventoryCallbacks + 1 };
enum { k_iCallback = k_iClientInventoryCallbacks + 1 }; SteamInventoryResult_t m_handle;
SteamInventoryResult_t m_handle;
}; };
// A SteamInventoryDefinitionUpdate_t callback is triggered whenever // A SteamInventoryDefinitionUpdate_t callback is triggered whenever
// item definitions have been updated, which could be in response to // item definitions have been updated, which could be in response to
// LoadItemDefinitions() or any other async request which required // LoadItemDefinitions() or any other async request which required
// a definition update in order to process results from the server. // a definition update in order to process results from the server.
struct SteamInventoryDefinitionUpdate_t struct SteamInventoryDefinitionUpdate_t {
{ enum { k_iCallback = k_iClientInventoryCallbacks + 2 };
enum { k_iCallback = k_iClientInventoryCallbacks + 2 };
}; };
// Returned // Returned
struct SteamInventoryEligiblePromoItemDefIDs_t struct SteamInventoryEligiblePromoItemDefIDs_t {
{ enum { k_iCallback = k_iClientInventoryCallbacks + 3 };
enum { k_iCallback = k_iClientInventoryCallbacks + 3 }; EResult m_result;
EResult m_result; CSteamID m_steamID;
CSteamID m_steamID; int m_numEligiblePromoItemDefs;
int m_numEligiblePromoItemDefs; bool m_bCachedData; // indicates that the data was retrieved from the cache and not the server
bool m_bCachedData; // indicates that the data was retrieved from the cache and not the server
}; };
// Triggered from StartPurchase call // Triggered from StartPurchase call
struct SteamInventoryStartPurchaseResult_t struct SteamInventoryStartPurchaseResult_t {
{ enum { k_iCallback = k_iClientInventoryCallbacks + 4 };
enum { k_iCallback = k_iClientInventoryCallbacks + 4 }; EResult m_result;
EResult m_result; uint64 m_ulOrderID;
uint64 m_ulOrderID; uint64 m_ulTransID;
uint64 m_ulTransID;
}; };
// Triggered from RequestPrices // Triggered from RequestPrices
struct SteamInventoryRequestPricesResult_t struct SteamInventoryRequestPricesResult_t {
{ enum { k_iCallback = k_iClientInventoryCallbacks + 5 };
enum { k_iCallback = k_iClientInventoryCallbacks + 5 }; EResult m_result;
EResult m_result; char m_rgchCurrency[4];
char m_rgchCurrency[4];
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMCONTROLLER_H #endif // ISTEAMCONTROLLER_H

File diff suppressed because it is too large Load Diff

View File

@ -9,63 +9,57 @@
#include "steam_api_common.h" #include "steam_api_common.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
enum AudioPlayback_Status enum AudioPlayback_Status {
{ AudioPlayback_Undefined = 0,
AudioPlayback_Undefined = 0, AudioPlayback_Playing = 1,
AudioPlayback_Playing = 1, AudioPlayback_Paused = 2,
AudioPlayback_Paused = 2, AudioPlayback_Idle = 3
AudioPlayback_Idle = 3
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions to control music playback in the steam client // Purpose: Functions to control music playback in the steam client
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamMusic class ISteamMusic {
{
public: public:
virtual bool BIsEnabled() = 0; virtual bool BIsEnabled() = 0;
virtual bool BIsPlaying() = 0; virtual bool BIsPlaying() = 0;
virtual AudioPlayback_Status GetPlaybackStatus() = 0;
virtual void Play() = 0; virtual AudioPlayback_Status GetPlaybackStatus() = 0;
virtual void Pause() = 0;
virtual void PlayPrevious() = 0;
virtual void PlayNext() = 0;
// volume is between 0.0 and 1.0 virtual void Play() = 0;
virtual void SetVolume( float flVolume ) = 0; virtual void Pause() = 0;
virtual float GetVolume() = 0; virtual void PlayPrevious() = 0;
virtual void PlayNext() = 0;
// volume is between 0.0 and 1.0
virtual void SetVolume(float flVolume) = 0;
virtual float GetVolume() = 0;
}; };
#define STEAMMUSIC_INTERFACE_VERSION "STEAMMUSIC_INTERFACE_VERSION001" #define STEAMMUSIC_INTERFACE_VERSION "STEAMMUSIC_INTERFACE_VERSION001"
// Global interface accessor // Global interface accessor
inline ISteamMusic *SteamMusic(); inline ISteamMusic* SteamMusic();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamMusic *, SteamMusic, STEAMMUSIC_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamMusic*, SteamMusic, STEAMMUSIC_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
STEAM_CALLBACK_BEGIN(PlaybackStatusHasChanged_t, k_iSteamMusicCallbacks + 1)
STEAM_CALLBACK_BEGIN( PlaybackStatusHasChanged_t, k_iSteamMusicCallbacks + 1 )
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( VolumeHasChanged_t, k_iSteamMusicCallbacks + 2 ) STEAM_CALLBACK_BEGIN(VolumeHasChanged_t, k_iSteamMusicCallbacks + 2)
STEAM_CALLBACK_MEMBER( 0, float, m_flNewVolume ) STEAM_CALLBACK_MEMBER(0, float, m_flNewVolume)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
#pragma pack( pop ) #pragma pack(pop)
#endif // #define ISTEAMMUSIC_H #endif // #define ISTEAMMUSIC_H

View File

@ -6,128 +6,123 @@
#pragma once #pragma once
#endif #endif
#include "steam_api_common.h"
#include "isteammusic.h" #include "isteammusic.h"
#include "steam_api_common.h"
#define k_SteamMusicNameMaxLength 255 #define k_SteamMusicNameMaxLength 255
#define k_SteamMusicPNGMaxLength 65535 #define k_SteamMusicPNGMaxLength 65535
class ISteamMusicRemote class ISteamMusicRemote {
{ public:
public: // Service Definition
// Service Definition virtual bool RegisterSteamMusicRemote(const char* pchName) = 0;
virtual bool RegisterSteamMusicRemote( const char *pchName ) = 0; virtual bool DeregisterSteamMusicRemote() = 0;
virtual bool DeregisterSteamMusicRemote() = 0; virtual bool BIsCurrentMusicRemote() = 0;
virtual bool BIsCurrentMusicRemote() = 0; virtual bool BActivationSuccess(bool bValue) = 0;
virtual bool BActivationSuccess( bool bValue ) = 0;
virtual bool SetDisplayName( const char *pchDisplayName ) = 0; virtual bool SetDisplayName(const char* pchDisplayName) = 0;
virtual bool SetPNGIcon_64x64( void *pvBuffer, uint32 cbBufferLength ) = 0; virtual bool SetPNGIcon_64x64(void* pvBuffer, uint32 cbBufferLength) = 0;
// Abilities for the user interface
virtual bool EnablePlayPrevious(bool bValue) = 0;
virtual bool EnablePlayNext( bool bValue ) = 0;
virtual bool EnableShuffled( bool bValue ) = 0;
virtual bool EnableLooped( bool bValue ) = 0;
virtual bool EnableQueue( bool bValue ) = 0;
virtual bool EnablePlaylists( bool bValue ) = 0;
// Status // Abilities for the user interface
virtual bool UpdatePlaybackStatus( AudioPlayback_Status nStatus ) = 0; virtual bool EnablePlayPrevious(bool bValue) = 0;
virtual bool UpdateShuffled( bool bValue ) = 0; virtual bool EnablePlayNext(bool bValue) = 0;
virtual bool UpdateLooped( bool bValue ) = 0; virtual bool EnableShuffled(bool bValue) = 0;
virtual bool UpdateVolume( float flValue ) = 0; // volume is between 0.0 and 1.0 virtual bool EnableLooped(bool bValue) = 0;
virtual bool EnableQueue(bool bValue) = 0;
virtual bool EnablePlaylists(bool bValue) = 0;
// Current Entry // Status
virtual bool CurrentEntryWillChange() = 0; virtual bool UpdatePlaybackStatus(AudioPlayback_Status nStatus) = 0;
virtual bool CurrentEntryIsAvailable( bool bAvailable ) = 0; virtual bool UpdateShuffled(bool bValue) = 0;
virtual bool UpdateCurrentEntryText( const char *pchText ) = 0; virtual bool UpdateLooped(bool bValue) = 0;
virtual bool UpdateCurrentEntryElapsedSeconds( int nValue ) = 0; virtual bool UpdateVolume(float flValue) = 0; // volume is between 0.0 and 1.0
virtual bool UpdateCurrentEntryCoverArt( void *pvBuffer, uint32 cbBufferLength ) = 0;
virtual bool CurrentEntryDidChange() = 0;
// Queue // Current Entry
virtual bool QueueWillChange() = 0; virtual bool CurrentEntryWillChange() = 0;
virtual bool ResetQueueEntries() = 0; virtual bool CurrentEntryIsAvailable(bool bAvailable) = 0;
virtual bool SetQueueEntry( int nID, int nPosition, const char *pchEntryText ) = 0; virtual bool UpdateCurrentEntryText(const char* pchText) = 0;
virtual bool SetCurrentQueueEntry( int nID ) = 0; virtual bool UpdateCurrentEntryElapsedSeconds(int nValue) = 0;
virtual bool QueueDidChange() = 0; virtual bool UpdateCurrentEntryCoverArt(void* pvBuffer, uint32 cbBufferLength) = 0;
virtual bool CurrentEntryDidChange() = 0;
// Playlist // Queue
virtual bool PlaylistWillChange() = 0; virtual bool QueueWillChange() = 0;
virtual bool ResetPlaylistEntries() = 0; virtual bool ResetQueueEntries() = 0;
virtual bool SetPlaylistEntry( int nID, int nPosition, const char *pchEntryText ) = 0; virtual bool SetQueueEntry(int nID, int nPosition, const char* pchEntryText) = 0;
virtual bool SetCurrentPlaylistEntry( int nID ) = 0; virtual bool SetCurrentQueueEntry(int nID) = 0;
virtual bool PlaylistDidChange() = 0; virtual bool QueueDidChange() = 0;
// Playlist
virtual bool PlaylistWillChange() = 0;
virtual bool ResetPlaylistEntries() = 0;
virtual bool SetPlaylistEntry(int nID, int nPosition, const char* pchEntryText) = 0;
virtual bool SetCurrentPlaylistEntry(int nID) = 0;
virtual bool PlaylistDidChange() = 0;
}; };
#define STEAMMUSICREMOTE_INTERFACE_VERSION "STEAMMUSICREMOTE_INTERFACE_VERSION001" #define STEAMMUSICREMOTE_INTERFACE_VERSION "STEAMMUSICREMOTE_INTERFACE_VERSION001"
// Global interface accessor // Global interface accessor
inline ISteamMusicRemote *SteamMusicRemote(); inline ISteamMusicRemote* SteamMusicRemote();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamMusicRemote *, SteamMusicRemote, STEAMMUSICREMOTE_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamMusicRemote*, SteamMusicRemote, STEAMMUSICREMOTE_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
STEAM_CALLBACK_BEGIN(MusicPlayerRemoteWillActivate_t, k_iSteamMusicRemoteCallbacks + 1)
STEAM_CALLBACK_BEGIN( MusicPlayerRemoteWillActivate_t, k_iSteamMusicRemoteCallbacks + 1)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerRemoteWillDeactivate_t, k_iSteamMusicRemoteCallbacks + 2 ) STEAM_CALLBACK_BEGIN(MusicPlayerRemoteWillDeactivate_t, k_iSteamMusicRemoteCallbacks + 2)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerRemoteToFront_t, k_iSteamMusicRemoteCallbacks + 3 ) STEAM_CALLBACK_BEGIN(MusicPlayerRemoteToFront_t, k_iSteamMusicRemoteCallbacks + 3)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerWillQuit_t, k_iSteamMusicRemoteCallbacks + 4 ) STEAM_CALLBACK_BEGIN(MusicPlayerWillQuit_t, k_iSteamMusicRemoteCallbacks + 4)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsPlay_t, k_iSteamMusicRemoteCallbacks + 5 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsPlay_t, k_iSteamMusicRemoteCallbacks + 5)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsPause_t, k_iSteamMusicRemoteCallbacks + 6 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsPause_t, k_iSteamMusicRemoteCallbacks + 6)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsPlayPrevious_t, k_iSteamMusicRemoteCallbacks + 7 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsPlayPrevious_t, k_iSteamMusicRemoteCallbacks + 7)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsPlayNext_t, k_iSteamMusicRemoteCallbacks + 8 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsPlayNext_t, k_iSteamMusicRemoteCallbacks + 8)
STEAM_CALLBACK_END(0) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsShuffled_t, k_iSteamMusicRemoteCallbacks + 9 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsShuffled_t, k_iSteamMusicRemoteCallbacks + 9)
STEAM_CALLBACK_MEMBER( 0, bool, m_bShuffled ) STEAM_CALLBACK_MEMBER(0, bool, m_bShuffled)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsLooped_t, k_iSteamMusicRemoteCallbacks + 10 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsLooped_t, k_iSteamMusicRemoteCallbacks + 10)
STEAM_CALLBACK_MEMBER(0, bool, m_bLooped ) STEAM_CALLBACK_MEMBER(0, bool, m_bLooped)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsVolume_t, k_iSteamMusicCallbacks + 11 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsVolume_t, k_iSteamMusicCallbacks + 11)
STEAM_CALLBACK_MEMBER(0, float, m_flNewVolume) STEAM_CALLBACK_MEMBER(0, float, m_flNewVolume)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
STEAM_CALLBACK_BEGIN( MusicPlayerSelectsQueueEntry_t, k_iSteamMusicCallbacks + 12 ) STEAM_CALLBACK_BEGIN(MusicPlayerSelectsQueueEntry_t, k_iSteamMusicCallbacks + 12)
STEAM_CALLBACK_MEMBER(0, int, nID ) STEAM_CALLBACK_MEMBER(0, int, nID)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
STEAM_CALLBACK_BEGIN( MusicPlayerSelectsPlaylistEntry_t, k_iSteamMusicCallbacks + 13 ) STEAM_CALLBACK_BEGIN(MusicPlayerSelectsPlaylistEntry_t, k_iSteamMusicCallbacks + 13)
STEAM_CALLBACK_MEMBER(0, int, nID ) STEAM_CALLBACK_MEMBER(0, int, nID)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
STEAM_CALLBACK_BEGIN( MusicPlayerWantsPlayingRepeatStatus_t, k_iSteamMusicRemoteCallbacks + 14 ) STEAM_CALLBACK_BEGIN(MusicPlayerWantsPlayingRepeatStatus_t, k_iSteamMusicRemoteCallbacks + 14)
STEAM_CALLBACK_MEMBER(0, int, m_nPlayingRepeatStatus ) STEAM_CALLBACK_MEMBER(0, int, m_nPlayingRepeatStatus)
STEAM_CALLBACK_END(1) STEAM_CALLBACK_END(1)
#pragma pack( pop ) #pragma pack(pop)
#endif // #define ISTEAMMUSICREMOTE_H #endif // #define ISTEAMMUSICREMOTE_H

View File

@ -14,113 +14,105 @@
// list of possible errors returned by SendP2PPacket() API // list of possible errors returned by SendP2PPacket() API
// these will be posted in the P2PSessionConnectFail_t callback // these will be posted in the P2PSessionConnectFail_t callback
enum EP2PSessionError enum EP2PSessionError {
{ k_EP2PSessionErrorNone = 0,
k_EP2PSessionErrorNone = 0, k_EP2PSessionErrorNoRightsToApp = 2, // local user doesn't own the app that is running
k_EP2PSessionErrorNoRightsToApp = 2, // local user doesn't own the app that is running k_EP2PSessionErrorTimeout = 4, // target isn't responding, perhaps not calling AcceptP2PSessionWithUser()
k_EP2PSessionErrorTimeout = 4, // target isn't responding, perhaps not calling AcceptP2PSessionWithUser() // corporate firewalls can also block this (NAT traversal is not firewall traversal)
// corporate firewalls can also block this (NAT traversal is not firewall traversal) // make sure that UDP ports 3478, 4379, and 4380 are open in an outbound direction
// make sure that UDP ports 3478, 4379, and 4380 are open in an outbound direction
// The following error codes were removed and will never be sent. // The following error codes were removed and will never be sent.
// For privacy reasons, there is no reply if the user is offline or playing another game. // For privacy reasons, there is no reply if the user is offline or playing another game.
k_EP2PSessionErrorNotRunningApp_DELETED = 1, k_EP2PSessionErrorNotRunningApp_DELETED = 1,
k_EP2PSessionErrorDestinationNotLoggedIn_DELETED = 3, k_EP2PSessionErrorDestinationNotLoggedIn_DELETED = 3,
k_EP2PSessionErrorMax = 5 k_EP2PSessionErrorMax = 5
}; };
// SendP2PPacket() send types // SendP2PPacket() send types
// Typically k_EP2PSendUnreliable is what you want for UDP-like packets, k_EP2PSendReliable for TCP-like packets // Typically k_EP2PSendUnreliable is what you want for UDP-like packets, k_EP2PSendReliable for TCP-like packets
enum EP2PSend enum EP2PSend {
{ // Basic UDP send. Packets can't be bigger than 1200 bytes (your typical MTU size). Can be lost, or arrive out of order (rare).
// Basic UDP send. Packets can't be bigger than 1200 bytes (your typical MTU size). Can be lost, or arrive out of order (rare). // The sending API does have some knowledge of the underlying connection, so if there is no NAT-traversal accomplished or
// The sending API does have some knowledge of the underlying connection, so if there is no NAT-traversal accomplished or // there is a recognized adjustment happening on the connection, the packet will be batched until the connection is open again.
// there is a recognized adjustment happening on the connection, the packet will be batched until the connection is open again. k_EP2PSendUnreliable = 0,
k_EP2PSendUnreliable = 0,
// As above, but if the underlying p2p connection isn't yet established the packet will just be thrown away. Using this on the first // As above, but if the underlying p2p connection isn't yet established the packet will just be thrown away. Using this on the first
// packet sent to a remote host almost guarantees the packet will be dropped. // packet sent to a remote host almost guarantees the packet will be dropped.
// This is only really useful for kinds of data that should never buffer up, i.e. voice payload packets // This is only really useful for kinds of data that should never buffer up, i.e. voice payload packets
k_EP2PSendUnreliableNoDelay = 1, k_EP2PSendUnreliableNoDelay = 1,
// Reliable message send. Can send up to 1MB of data in a single message. // Reliable message send. Can send up to 1MB of data in a single message.
// Does fragmentation/re-assembly of messages under the hood, as well as a sliding window for efficient sends of large chunks of data. // Does fragmentation/re-assembly of messages under the hood, as well as a sliding window for efficient sends of large chunks of data.
k_EP2PSendReliable = 2, k_EP2PSendReliable = 2,
// As above, but applies the Nagle algorithm to the send - sends will accumulate // As above, but applies the Nagle algorithm to the send - sends will accumulate
// until the current MTU size (typically ~1200 bytes, but can change) or ~200ms has passed (Nagle algorithm). // until the current MTU size (typically ~1200 bytes, but can change) or ~200ms has passed (Nagle algorithm).
// Useful if you want to send a set of smaller messages but have the coalesced into a single packet // Useful if you want to send a set of smaller messages but have the coalesced into a single packet
// Since the reliable stream is all ordered, you can do several small message sends with k_EP2PSendReliableWithBuffering and then // Since the reliable stream is all ordered, you can do several small message sends with k_EP2PSendReliableWithBuffering and then
// do a normal k_EP2PSendReliable to force all the buffered data to be sent. // do a normal k_EP2PSendReliable to force all the buffered data to be sent.
k_EP2PSendReliableWithBuffering = 3, k_EP2PSendReliableWithBuffering = 3,
}; };
// connection state to a specified user, returned by GetP2PSessionState() // connection state to a specified user, returned by GetP2PSessionState()
// this is under-the-hood info about what's going on with a SendP2PPacket(), shouldn't be needed except for debuggin // this is under-the-hood info about what's going on with a SendP2PPacket(), shouldn't be needed except for debuggin
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
struct P2PSessionState_t struct P2PSessionState_t {
{ uint8 m_bConnectionActive; // true if we've got an active open connection
uint8 m_bConnectionActive; // true if we've got an active open connection uint8 m_bConnecting; // true if we're currently trying to establish a connection
uint8 m_bConnecting; // true if we're currently trying to establish a connection uint8 m_eP2PSessionError; // last error recorded (see enum above)
uint8 m_eP2PSessionError; // last error recorded (see enum above) uint8 m_bUsingRelay; // true if it's going through a relay server (TURN)
uint8 m_bUsingRelay; // true if it's going through a relay server (TURN) int32 m_nBytesQueuedForSend;
int32 m_nBytesQueuedForSend; int32 m_nPacketsQueuedForSend;
int32 m_nPacketsQueuedForSend; uint32 m_nRemoteIP; // potential IP:Port of remote host. Could be TURN server.
uint32 m_nRemoteIP; // potential IP:Port of remote host. Could be TURN server. uint16 m_nRemotePort; // Only exists for compatibility with older authentication api's
uint16 m_nRemotePort; // Only exists for compatibility with older authentication api's
}; };
#pragma pack( pop ) #pragma pack(pop)
// handle to a socket // handle to a socket
typedef uint32 SNetSocket_t; // CreateP2PConnectionSocket() typedef uint32 SNetSocket_t; // CreateP2PConnectionSocket()
typedef uint32 SNetListenSocket_t; // CreateListenSocket() typedef uint32 SNetListenSocket_t; // CreateListenSocket()
// connection progress indicators, used by CreateP2PConnectionSocket() // connection progress indicators, used by CreateP2PConnectionSocket()
enum ESNetSocketState enum ESNetSocketState {
{ k_ESNetSocketStateInvalid = 0,
k_ESNetSocketStateInvalid = 0,
// communication is valid // communication is valid
k_ESNetSocketStateConnected = 1, k_ESNetSocketStateConnected = 1,
// states while establishing a connection
k_ESNetSocketStateInitiated = 10, // the connection state machine has started
// p2p connections // states while establishing a connection
k_ESNetSocketStateLocalCandidatesFound = 11, // we've found our local IP info k_ESNetSocketStateInitiated = 10, // the connection state machine has started
k_ESNetSocketStateReceivedRemoteCandidates = 12,// we've received information from the remote machine, via the Steam back-end, about their IP info
// direct connections // p2p connections
k_ESNetSocketStateChallengeHandshake = 15, // we've received a challenge packet from the server k_ESNetSocketStateLocalCandidatesFound = 11, // we've found our local IP info
k_ESNetSocketStateReceivedRemoteCandidates = 12, // we've received information from the remote machine, via the Steam back-end, about their IP info
// failure states // direct connections
k_ESNetSocketStateDisconnecting = 21, // the API shut it down, and we're in the process of telling the other end k_ESNetSocketStateChallengeHandshake = 15, // we've received a challenge packet from the server
k_ESNetSocketStateLocalDisconnect = 22, // the API shut it down, and we've completed shutdown
k_ESNetSocketStateTimeoutDuringConnect = 23, // we timed out while trying to creating the connection // failure states
k_ESNetSocketStateRemoteEndDisconnected = 24, // the remote end has disconnected from us k_ESNetSocketStateDisconnecting = 21, // the API shut it down, and we're in the process of telling the other end
k_ESNetSocketStateConnectionBroken = 25, // connection has been broken; either the other end has disappeared or our local network connection has broke k_ESNetSocketStateLocalDisconnect = 22, // the API shut it down, and we've completed shutdown
k_ESNetSocketStateTimeoutDuringConnect = 23, // we timed out while trying to creating the connection
k_ESNetSocketStateRemoteEndDisconnected = 24, // the remote end has disconnected from us
k_ESNetSocketStateConnectionBroken = 25, // connection has been broken; either the other end has disappeared or our local network connection has broke
}; };
// describes how the socket is currently connected // describes how the socket is currently connected
enum ESNetSocketConnectionType enum ESNetSocketConnectionType {
{ k_ESNetSocketConnectionTypeNotConnected = 0,
k_ESNetSocketConnectionTypeNotConnected = 0, k_ESNetSocketConnectionTypeUDP = 1,
k_ESNetSocketConnectionTypeUDP = 1, k_ESNetSocketConnectionTypeUDPRelay = 2,
k_ESNetSocketConnectionTypeUDPRelay = 2,
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for making connections and sending data between clients, // Purpose: Functions for making connections and sending data between clients,
// traversing NAT's where possible // traversing NAT's where possible
@ -129,215 +121,207 @@ enum ESNetSocketConnectionType
/// the Steamworks SDK. Please see ISteamNetworkingSockets and /// the Steamworks SDK. Please see ISteamNetworkingSockets and
/// ISteamNetworkingMessages /// ISteamNetworkingMessages
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamNetworking class ISteamNetworking {
{
public: public:
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
// //
// UDP-style (connectionless) networking interface. These functions send messages using // UDP-style (connectionless) networking interface. These functions send messages using
// an API organized around the destination. Reliable and unreliable messages are supported. // an API organized around the destination. Reliable and unreliable messages are supported.
// //
// For a more TCP-style interface (meaning you have a connection handle), see the functions below. // For a more TCP-style interface (meaning you have a connection handle), see the functions below.
// Both interface styles can send both reliable and unreliable messages. // Both interface styles can send both reliable and unreliable messages.
// //
// Automatically establishes NAT-traversing or Relay server connections // Automatically establishes NAT-traversing or Relay server connections
// //
// These APIs are deprecated, and may be removed in a future version of the Steamworks // These APIs are deprecated, and may be removed in a future version of the Steamworks
// SDK. See ISteamNetworkingMessages. // SDK. See ISteamNetworkingMessages.
// Sends a P2P packet to the specified user // Sends a P2P packet to the specified user
// UDP-like, unreliable and a max packet size of 1200 bytes // UDP-like, unreliable and a max packet size of 1200 bytes
// the first packet send may be delayed as the NAT-traversal code runs // the first packet send may be delayed as the NAT-traversal code runs
// if we can't get through to the user, an error will be posted via the callback P2PSessionConnectFail_t // if we can't get through to the user, an error will be posted via the callback P2PSessionConnectFail_t
// see EP2PSend enum above for the descriptions of the different ways of sending packets // see EP2PSend enum above for the descriptions of the different ways of sending packets
// //
// nChannel is a routing number you can use to help route message to different systems - you'll have to call ReadP2PPacket() // nChannel is a routing number you can use to help route message to different systems - you'll have to call ReadP2PPacket()
// with the same channel number in order to retrieve the data on the other end // with the same channel number in order to retrieve the data on the other end
// using different channels to talk to the same user will still use the same underlying p2p connection, saving on resources // using different channels to talk to the same user will still use the same underlying p2p connection, saving on resources
virtual bool SendP2PPacket( CSteamID steamIDRemote, const void *pubData, uint32 cubData, EP2PSend eP2PSendType, int nChannel = 0 ) = 0; virtual bool SendP2PPacket(CSteamID steamIDRemote, const void* pubData, uint32 cubData, EP2PSend eP2PSendType, int nChannel = 0) = 0;
// returns true if any data is available for read, and the amount of data that will need to be read // returns true if any data is available for read, and the amount of data that will need to be read
virtual bool IsP2PPacketAvailable( uint32 *pcubMsgSize, int nChannel = 0 ) = 0; virtual bool IsP2PPacketAvailable(uint32* pcubMsgSize, int nChannel = 0) = 0;
// reads in a packet that has been sent from another user via SendP2PPacket() // reads in a packet that has been sent from another user via SendP2PPacket()
// returns the size of the message and the steamID of the user who sent it in the last two parameters // returns the size of the message and the steamID of the user who sent it in the last two parameters
// if the buffer passed in is too small, the message will be truncated // if the buffer passed in is too small, the message will be truncated
// this call is not blocking, and will return false if no data is available // this call is not blocking, and will return false if no data is available
virtual bool ReadP2PPacket( void *pubDest, uint32 cubDest, uint32 *pcubMsgSize, CSteamID *psteamIDRemote, int nChannel = 0 ) = 0; virtual bool ReadP2PPacket(void* pubDest, uint32 cubDest, uint32* pcubMsgSize, CSteamID* psteamIDRemote, int nChannel = 0) = 0;
// AcceptP2PSessionWithUser() should only be called in response to a P2PSessionRequest_t callback // AcceptP2PSessionWithUser() should only be called in response to a P2PSessionRequest_t callback
// P2PSessionRequest_t will be posted if another user tries to send you a packet that you haven't talked to yet // P2PSessionRequest_t will be posted if another user tries to send you a packet that you haven't talked to yet
// if you don't want to talk to the user, just ignore the request // if you don't want to talk to the user, just ignore the request
// if the user continues to send you packets, another P2PSessionRequest_t will be posted periodically // if the user continues to send you packets, another P2PSessionRequest_t will be posted periodically
// this may be called multiple times for a single user // this may be called multiple times for a single user
// (if you've called SendP2PPacket() on the other user, this implicitly accepts the session request) // (if you've called SendP2PPacket() on the other user, this implicitly accepts the session request)
virtual bool AcceptP2PSessionWithUser( CSteamID steamIDRemote ) = 0; virtual bool AcceptP2PSessionWithUser(CSteamID steamIDRemote) = 0;
// call CloseP2PSessionWithUser() when you're done talking to a user, will free up resources under-the-hood // call CloseP2PSessionWithUser() when you're done talking to a user, will free up resources under-the-hood
// if the remote user tries to send data to you again, another P2PSessionRequest_t callback will be posted // if the remote user tries to send data to you again, another P2PSessionRequest_t callback will be posted
virtual bool CloseP2PSessionWithUser( CSteamID steamIDRemote ) = 0; virtual bool CloseP2PSessionWithUser(CSteamID steamIDRemote) = 0;
// call CloseP2PChannelWithUser() when you're done talking to a user on a specific channel. Once all channels // call CloseP2PChannelWithUser() when you're done talking to a user on a specific channel. Once all channels
// open channels to a user have been closed, the open session to the user will be closed and new data from this // open channels to a user have been closed, the open session to the user will be closed and new data from this
// user will trigger a P2PSessionRequest_t callback // user will trigger a P2PSessionRequest_t callback
virtual bool CloseP2PChannelWithUser( CSteamID steamIDRemote, int nChannel ) = 0; virtual bool CloseP2PChannelWithUser(CSteamID steamIDRemote, int nChannel) = 0;
// fills out P2PSessionState_t structure with details about the underlying connection to the user // fills out P2PSessionState_t structure with details about the underlying connection to the user
// should only needed for debugging purposes // should only needed for debugging purposes
// returns false if no connection exists to the specified user // returns false if no connection exists to the specified user
virtual bool GetP2PSessionState( CSteamID steamIDRemote, P2PSessionState_t *pConnectionState ) = 0; virtual bool GetP2PSessionState(CSteamID steamIDRemote, P2PSessionState_t* pConnectionState) = 0;
// Allow P2P connections to fall back to being relayed through the Steam servers if a direct connection // Allow P2P connections to fall back to being relayed through the Steam servers if a direct connection
// or NAT-traversal cannot be established. Only applies to connections created after setting this value, // or NAT-traversal cannot be established. Only applies to connections created after setting this value,
// or to existing connections that need to automatically reconnect after this value is set. // or to existing connections that need to automatically reconnect after this value is set.
// //
// P2P packet relay is allowed by default // P2P packet relay is allowed by default
// //
// NOTE: This function is deprecated and may be removed in a future version of the SDK. For // NOTE: This function is deprecated and may be removed in a future version of the SDK. For
// security purposes, we may decide to relay the traffic to certain peers, even if you pass false // security purposes, we may decide to relay the traffic to certain peers, even if you pass false
// to this function, to prevent revealing the client's IP address top another peer. // to this function, to prevent revealing the client's IP address top another peer.
virtual bool AllowP2PPacketRelay( bool bAllow ) = 0; virtual bool AllowP2PPacketRelay(bool bAllow) = 0;
////////////////////////////////////////////////////////////////////////////////////////////
//
// LISTEN / CONNECT connection-oriented interface functions
//
// These functions are more like a client-server TCP API. One side is the "server"
// and "listens" for incoming connections, which then must be "accepted." The "client"
// initiates a connection by "connecting." Sending and receiving is done through a
// connection handle.
//
// For a more UDP-style interface, where you do not track connection handles but
// simply send messages to a SteamID, use the UDP-style functions above.
//
// Both methods can send both reliable and unreliable methods.
//
// These APIs are deprecated, and may be removed in a future version of the Steamworks
// SDK. See ISteamNetworkingSockets.
//
////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////// // creates a socket and listens others to connect
// // will trigger a SocketStatusCallback_t callback on another client connecting
// LISTEN / CONNECT connection-oriented interface functions // nVirtualP2PPort is the unique ID that the client will connect to, in case you have multiple ports
// // this can usually just be 0 unless you want multiple sets of connections
// These functions are more like a client-server TCP API. One side is the "server" // unIP is the local IP address to bind to
// and "listens" for incoming connections, which then must be "accepted." The "client" // pass in 0 if you just want the default local IP
// initiates a connection by "connecting." Sending and receiving is done through a // unPort is the port to use
// connection handle. // pass in 0 if you don't want users to be able to connect via IP/Port, but expect to be always peer-to-peer connections only
// virtual SNetListenSocket_t CreateListenSocket(int nVirtualP2PPort, SteamIPAddress_t nIP, uint16 nPort, bool bAllowUseOfPacketRelay) = 0;
// For a more UDP-style interface, where you do not track connection handles but
// simply send messages to a SteamID, use the UDP-style functions above.
//
// Both methods can send both reliable and unreliable methods.
//
// These APIs are deprecated, and may be removed in a future version of the Steamworks
// SDK. See ISteamNetworkingSockets.
//
////////////////////////////////////////////////////////////////////////////////////////////
// creates a socket and begin connection to a remote destination
// can connect via a known steamID (client or game server), or directly to an IP
// on success will trigger a SocketStatusCallback_t callback
// on failure or timeout will trigger a SocketStatusCallback_t callback with a failure code in m_eSNetSocketState
virtual SNetSocket_t CreateP2PConnectionSocket(CSteamID steamIDTarget, int nVirtualPort, int nTimeoutSec, bool bAllowUseOfPacketRelay) = 0;
virtual SNetSocket_t CreateConnectionSocket(SteamIPAddress_t nIP, uint16 nPort, int nTimeoutSec) = 0;
// creates a socket and listens others to connect // disconnects the connection to the socket, if any, and invalidates the handle
// will trigger a SocketStatusCallback_t callback on another client connecting // any unread data on the socket will be thrown away
// nVirtualP2PPort is the unique ID that the client will connect to, in case you have multiple ports // if bNotifyRemoteEnd is set, socket will not be completely destroyed until the remote end acknowledges the disconnect
// this can usually just be 0 unless you want multiple sets of connections virtual bool DestroySocket(SNetSocket_t hSocket, bool bNotifyRemoteEnd) = 0;
// unIP is the local IP address to bind to // destroying a listen socket will automatically kill all the regular sockets generated from it
// pass in 0 if you just want the default local IP virtual bool DestroyListenSocket(SNetListenSocket_t hSocket, bool bNotifyRemoteEnd) = 0;
// unPort is the port to use
// pass in 0 if you don't want users to be able to connect via IP/Port, but expect to be always peer-to-peer connections only
virtual SNetListenSocket_t CreateListenSocket( int nVirtualP2PPort, SteamIPAddress_t nIP, uint16 nPort, bool bAllowUseOfPacketRelay ) = 0;
// creates a socket and begin connection to a remote destination // sending data
// can connect via a known steamID (client or game server), or directly to an IP // must be a handle to a connected socket
// on success will trigger a SocketStatusCallback_t callback // data is all sent via UDP, and thus send sizes are limited to 1200 bytes; after this, many routers will start dropping packets
// on failure or timeout will trigger a SocketStatusCallback_t callback with a failure code in m_eSNetSocketState // use the reliable flag with caution; although the resend rate is pretty aggressive,
virtual SNetSocket_t CreateP2PConnectionSocket( CSteamID steamIDTarget, int nVirtualPort, int nTimeoutSec, bool bAllowUseOfPacketRelay ) = 0; // it can still cause stalls in receiving data (like TCP)
virtual SNetSocket_t CreateConnectionSocket( SteamIPAddress_t nIP, uint16 nPort, int nTimeoutSec ) = 0; virtual bool SendDataOnSocket(SNetSocket_t hSocket, void* pubData, uint32 cubData, bool bReliable) = 0;
// disconnects the connection to the socket, if any, and invalidates the handle // receiving data
// any unread data on the socket will be thrown away // returns false if there is no data remaining
// if bNotifyRemoteEnd is set, socket will not be completely destroyed until the remote end acknowledges the disconnect // fills out *pcubMsgSize with the size of the next message, in bytes
virtual bool DestroySocket( SNetSocket_t hSocket, bool bNotifyRemoteEnd ) = 0; virtual bool IsDataAvailableOnSocket(SNetSocket_t hSocket, uint32* pcubMsgSize) = 0;
// destroying a listen socket will automatically kill all the regular sockets generated from it
virtual bool DestroyListenSocket( SNetListenSocket_t hSocket, bool bNotifyRemoteEnd ) = 0;
// sending data // fills in pubDest with the contents of the message
// must be a handle to a connected socket // messages are always complete, of the same size as was sent (i.e. packetized, not streaming)
// data is all sent via UDP, and thus send sizes are limited to 1200 bytes; after this, many routers will start dropping packets // if *pcubMsgSize < cubDest, only partial data is written
// use the reliable flag with caution; although the resend rate is pretty aggressive, // returns false if no data is available
// it can still cause stalls in receiving data (like TCP) virtual bool RetrieveDataFromSocket(SNetSocket_t hSocket, void* pubDest, uint32 cubDest, uint32* pcubMsgSize) = 0;
virtual bool SendDataOnSocket( SNetSocket_t hSocket, void *pubData, uint32 cubData, bool bReliable ) = 0;
// receiving data // checks for data from any socket that has been connected off this listen socket
// returns false if there is no data remaining // returns false if there is no data remaining
// fills out *pcubMsgSize with the size of the next message, in bytes // fills out *pcubMsgSize with the size of the next message, in bytes
virtual bool IsDataAvailableOnSocket( SNetSocket_t hSocket, uint32 *pcubMsgSize ) = 0; // fills out *phSocket with the socket that data is available on
virtual bool IsDataAvailable(SNetListenSocket_t hListenSocket, uint32* pcubMsgSize, SNetSocket_t* phSocket) = 0;
// fills in pubDest with the contents of the message // retrieves data from any socket that has been connected off this listen socket
// messages are always complete, of the same size as was sent (i.e. packetized, not streaming) // fills in pubDest with the contents of the message
// if *pcubMsgSize < cubDest, only partial data is written // messages are always complete, of the same size as was sent (i.e. packetized, not streaming)
// returns false if no data is available // if *pcubMsgSize < cubDest, only partial data is written
virtual bool RetrieveDataFromSocket( SNetSocket_t hSocket, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize ) = 0; // returns false if no data is available
// fills out *phSocket with the socket that data is available on
virtual bool RetrieveData(SNetListenSocket_t hListenSocket, void* pubDest, uint32 cubDest, uint32* pcubMsgSize, SNetSocket_t* phSocket) = 0;
// checks for data from any socket that has been connected off this listen socket // returns information about the specified socket, filling out the contents of the pointers
// returns false if there is no data remaining virtual bool GetSocketInfo(SNetSocket_t hSocket, CSteamID* pSteamIDRemote, int* peSocketStatus, SteamIPAddress_t* punIPRemote, uint16* punPortRemote) = 0;
// fills out *pcubMsgSize with the size of the next message, in bytes
// fills out *phSocket with the socket that data is available on
virtual bool IsDataAvailable( SNetListenSocket_t hListenSocket, uint32 *pcubMsgSize, SNetSocket_t *phSocket ) = 0;
// retrieves data from any socket that has been connected off this listen socket // returns which local port the listen socket is bound to
// fills in pubDest with the contents of the message // *pnIP and *pnPort will be 0 if the socket is set to listen for P2P connections only
// messages are always complete, of the same size as was sent (i.e. packetized, not streaming) virtual bool GetListenSocketInfo(SNetListenSocket_t hListenSocket, SteamIPAddress_t* pnIP, uint16* pnPort) = 0;
// if *pcubMsgSize < cubDest, only partial data is written
// returns false if no data is available
// fills out *phSocket with the socket that data is available on
virtual bool RetrieveData( SNetListenSocket_t hListenSocket, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize, SNetSocket_t *phSocket ) = 0;
// returns information about the specified socket, filling out the contents of the pointers // returns true to describe how the socket ended up connecting
virtual bool GetSocketInfo( SNetSocket_t hSocket, CSteamID *pSteamIDRemote, int *peSocketStatus, SteamIPAddress_t *punIPRemote, uint16 *punPortRemote ) = 0; virtual ESNetSocketConnectionType GetSocketConnectionType(SNetSocket_t hSocket) = 0;
// returns which local port the listen socket is bound to // max packet size, in bytes
// *pnIP and *pnPort will be 0 if the socket is set to listen for P2P connections only virtual int GetMaxPacketSize(SNetSocket_t hSocket) = 0;
virtual bool GetListenSocketInfo( SNetListenSocket_t hListenSocket, SteamIPAddress_t *pnIP, uint16 *pnPort ) = 0;
// returns true to describe how the socket ended up connecting
virtual ESNetSocketConnectionType GetSocketConnectionType( SNetSocket_t hSocket ) = 0;
// max packet size, in bytes
virtual int GetMaxPacketSize( SNetSocket_t hSocket ) = 0;
}; };
#define STEAMNETWORKING_INTERFACE_VERSION "SteamNetworking006" #define STEAMNETWORKING_INTERFACE_VERSION "SteamNetworking006"
// Global interface accessor // Global interface accessor
inline ISteamNetworking *SteamNetworking(); inline ISteamNetworking* SteamNetworking();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamNetworking *, SteamNetworking, STEAMNETWORKING_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamNetworking*, SteamNetworking, STEAMNETWORKING_INTERFACE_VERSION);
// Global accessor for the gameserver client // Global accessor for the gameserver client
inline ISteamNetworking *SteamGameServerNetworking(); inline ISteamNetworking* SteamGameServerNetworking();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamNetworking *, SteamGameServerNetworking, STEAMNETWORKING_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamNetworking*, SteamGameServerNetworking, STEAMNETWORKING_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
// callback notification - a user wants to talk to us over the P2P channel via the SendP2PPacket() API // callback notification - a user wants to talk to us over the P2P channel via the SendP2PPacket() API
// in response, a call to AcceptP2PPacketsFromUser() needs to be made, if you want to talk with them // in response, a call to AcceptP2PPacketsFromUser() needs to be made, if you want to talk with them
struct P2PSessionRequest_t struct P2PSessionRequest_t {
{ enum { k_iCallback = k_iSteamNetworkingCallbacks + 2 };
enum { k_iCallback = k_iSteamNetworkingCallbacks + 2 }; CSteamID m_steamIDRemote; // user who wants to talk to us
CSteamID m_steamIDRemote; // user who wants to talk to us
}; };
// callback notification - packets can't get through to the specified user via the SendP2PPacket() API // callback notification - packets can't get through to the specified user via the SendP2PPacket() API
// all packets queued packets unsent at this point will be dropped // all packets queued packets unsent at this point will be dropped
// further attempts to send will retry making the connection (but will be dropped if we fail again) // further attempts to send will retry making the connection (but will be dropped if we fail again)
struct P2PSessionConnectFail_t struct P2PSessionConnectFail_t {
{ enum { k_iCallback = k_iSteamNetworkingCallbacks + 3 };
enum { k_iCallback = k_iSteamNetworkingCallbacks + 3 }; CSteamID m_steamIDRemote; // user we were sending packets to
CSteamID m_steamIDRemote; // user we were sending packets to uint8 m_eP2PSessionError; // EP2PSessionError indicating why we're having trouble
uint8 m_eP2PSessionError; // EP2PSessionError indicating why we're having trouble
}; };
// callback notification - status of a socket has changed // callback notification - status of a socket has changed
// used as part of the CreateListenSocket() / CreateP2PConnectionSocket() // used as part of the CreateListenSocket() / CreateP2PConnectionSocket()
struct SocketStatusCallback_t struct SocketStatusCallback_t {
{ enum { k_iCallback = k_iSteamNetworkingCallbacks + 1 };
enum { k_iCallback = k_iSteamNetworkingCallbacks + 1 }; SNetSocket_t m_hSocket; // the socket used to send/receive data to the remote host
SNetSocket_t m_hSocket; // the socket used to send/receive data to the remote host SNetListenSocket_t m_hListenSocket; // this is the server socket that we were listening on; NULL if this was an outgoing connection
SNetListenSocket_t m_hListenSocket; // this is the server socket that we were listening on; NULL if this was an outgoing connection CSteamID m_steamIDRemote; // remote steamID we have connected to, if it has one
CSteamID m_steamIDRemote; // remote steamID we have connected to, if it has one int m_eSNetSocketState; // socket state, ESNetSocketState
int m_eSNetSocketState; // socket state, ESNetSocketState
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMNETWORKING #endif // ISTEAMNETWORKING

View File

@ -4,8 +4,8 @@
#define ISTEAMNETWORKINGMESSAGES #define ISTEAMNETWORKINGMESSAGES
#pragma once #pragma once
#include "steamnetworkingtypes.h"
#include "steam_api_common.h" #include "steam_api_common.h"
#include "steamnetworkingtypes.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// The non-connection-oriented interface to send and receive messages /// The non-connection-oriented interface to send and receive messages
@ -33,94 +33,93 @@
/// you may find the symmetric connection mode of ISteamNetworkingSockets useful. /// you may find the symmetric connection mode of ISteamNetworkingSockets useful.
/// (See k_ESteamNetworkingConfig_SymmetricConnect.) /// (See k_ESteamNetworkingConfig_SymmetricConnect.)
/// ///
class ISteamNetworkingMessages class ISteamNetworkingMessages {
{
public: public:
/// Sends a message to the specified host. If we don't already have a session with that user, /// Sends a message to the specified host. If we don't already have a session with that user,
/// a session is implicitly created. There might be some handshaking that needs to happen /// a session is implicitly created. There might be some handshaking that needs to happen
/// before we can actually begin sending message data. If this handshaking fails and we can't /// before we can actually begin sending message data. If this handshaking fails and we can't
/// get through, an error will be posted via the callback SteamNetworkingMessagesSessionFailed_t. /// get through, an error will be posted via the callback SteamNetworkingMessagesSessionFailed_t.
/// There is no notification when the operation succeeds. (You should have the peer send a reply /// There is no notification when the operation succeeds. (You should have the peer send a reply
/// for this purpose.) /// for this purpose.)
/// ///
/// Sending a message to a host will also implicitly accept any incoming connection from that host. /// Sending a message to a host will also implicitly accept any incoming connection from that host.
/// ///
/// nSendFlags is a bitmask of k_nSteamNetworkingSend_xxx options /// nSendFlags is a bitmask of k_nSteamNetworkingSend_xxx options
/// ///
/// nRemoteChannel is a routing number you can use to help route message to different systems. /// nRemoteChannel is a routing number you can use to help route message to different systems.
/// You'll have to call ReceiveMessagesOnChannel() with the same channel number in order to retrieve /// You'll have to call ReceiveMessagesOnChannel() with the same channel number in order to retrieve
/// the data on the other end. /// the data on the other end.
/// ///
/// Using different channels to talk to the same user will still use the same underlying /// Using different channels to talk to the same user will still use the same underlying
/// connection, saving on resources. If you don't need this feature, use 0. /// connection, saving on resources. If you don't need this feature, use 0.
/// Otherwise, small integers are the most efficient. /// Otherwise, small integers are the most efficient.
/// ///
/// It is guaranteed that reliable messages to the same host on the same channel /// It is guaranteed that reliable messages to the same host on the same channel
/// will be be received by the remote host (if they are received at all) exactly once, /// will be be received by the remote host (if they are received at all) exactly once,
/// and in the same order that they were sent. /// and in the same order that they were sent.
/// ///
/// NO other order guarantees exist! In particular, unreliable messages may be dropped, /// NO other order guarantees exist! In particular, unreliable messages may be dropped,
/// received out of order with respect to each other and with respect to reliable data, /// received out of order with respect to each other and with respect to reliable data,
/// or may be received multiple times. Messages on different channels are *not* guaranteed /// or may be received multiple times. Messages on different channels are *not* guaranteed
/// to be received in the order they were sent. /// to be received in the order they were sent.
/// ///
/// A note for those familiar with TCP/IP ports, or converting an existing codebase that /// A note for those familiar with TCP/IP ports, or converting an existing codebase that
/// opened multiple sockets: You might notice that there is only one channel, and with /// opened multiple sockets: You might notice that there is only one channel, and with
/// TCP/IP each endpoint has a port number. You can think of the channel number as the /// TCP/IP each endpoint has a port number. You can think of the channel number as the
/// *destination* port. If you need each message to also include a "source port" (so the /// *destination* port. If you need each message to also include a "source port" (so the
/// recipient can route the reply), then just put that in your message. That is essentially /// recipient can route the reply), then just put that in your message. That is essentially
/// how UDP works! /// how UDP works!
/// ///
/// Returns: /// Returns:
/// - k_EREsultOK on success. /// - k_EREsultOK on success.
/// - k_EResultNoConnection will be returned if the session has failed or was closed by the peer, /// - k_EResultNoConnection will be returned if the session has failed or was closed by the peer,
/// and k_nSteamNetworkingSend_AutoRestartBrokenSession is not used. (You can use /// and k_nSteamNetworkingSend_AutoRestartBrokenSession is not used. (You can use
/// GetSessionConnectionInfo to get the details.) In order to acknowledge the broken session /// GetSessionConnectionInfo to get the details.) In order to acknowledge the broken session
/// and start a new one, you must call CloseSessionWithUser /// and start a new one, you must call CloseSessionWithUser
/// - See ISteamNetworkingSockets::SendMessageToConnection for more possible return values /// - See ISteamNetworkingSockets::SendMessageToConnection for more possible return values
virtual EResult SendMessageToUser( const SteamNetworkingIdentity &identityRemote, const void *pubData, uint32 cubData, int nSendFlags, int nRemoteChannel ) = 0; virtual EResult SendMessageToUser(const SteamNetworkingIdentity& identityRemote, const void* pubData, uint32 cubData, int nSendFlags, int nRemoteChannel) = 0;
/// Reads the next message that has been sent from another user via SendMessageToUser() on the given channel. /// Reads the next message that has been sent from another user via SendMessageToUser() on the given channel.
/// Returns number of messages returned into your list. (0 if no message are available on that channel.) /// Returns number of messages returned into your list. (0 if no message are available on that channel.)
/// ///
/// When you're done with the message object(s), make sure and call SteamNetworkingMessage_t::Release()! /// When you're done with the message object(s), make sure and call SteamNetworkingMessage_t::Release()!
virtual int ReceiveMessagesOnChannel( int nLocalChannel, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages ) = 0; virtual int ReceiveMessagesOnChannel(int nLocalChannel, SteamNetworkingMessage_t** ppOutMessages, int nMaxMessages) = 0;
/// Call this in response to a SteamNetworkingMessagesSessionRequest_t callback. /// Call this in response to a SteamNetworkingMessagesSessionRequest_t callback.
/// SteamNetworkingMessagesSessionRequest_t are posted when a user tries to send you a message, /// SteamNetworkingMessagesSessionRequest_t are posted when a user tries to send you a message,
/// and you haven't tried to talk to them first. If you don't want to talk to them, just ignore /// and you haven't tried to talk to them first. If you don't want to talk to them, just ignore
/// the request. If the user continues to send you messages, SteamNetworkingMessagesSessionRequest_t /// the request. If the user continues to send you messages, SteamNetworkingMessagesSessionRequest_t
/// callbacks will continue to be posted periodically. /// callbacks will continue to be posted periodically.
/// ///
/// Returns false if there is no session with the user pending or otherwise. If there is an /// Returns false if there is no session with the user pending or otherwise. If there is an
/// existing active session, this function will return true, even if it is not pending. /// existing active session, this function will return true, even if it is not pending.
/// ///
/// Calling SendMessageToUser() will implicitly accepts any pending session request to that user. /// Calling SendMessageToUser() will implicitly accepts any pending session request to that user.
virtual bool AcceptSessionWithUser( const SteamNetworkingIdentity &identityRemote ) = 0; virtual bool AcceptSessionWithUser(const SteamNetworkingIdentity& identityRemote) = 0;
/// Call this when you're done talking to a user to immediately free up resources under-the-hood. /// Call this when you're done talking to a user to immediately free up resources under-the-hood.
/// If the remote user tries to send data to you again, another SteamNetworkingMessagesSessionRequest_t /// If the remote user tries to send data to you again, another SteamNetworkingMessagesSessionRequest_t
/// callback will be posted. /// callback will be posted.
/// ///
/// Note that sessions that go unused for a few minutes are automatically timed out. /// Note that sessions that go unused for a few minutes are automatically timed out.
virtual bool CloseSessionWithUser( const SteamNetworkingIdentity &identityRemote ) = 0; virtual bool CloseSessionWithUser(const SteamNetworkingIdentity& identityRemote) = 0;
/// Call this when you're done talking to a user on a specific channel. Once all /// Call this when you're done talking to a user on a specific channel. Once all
/// open channels to a user have been closed, the open session to the user will be /// open channels to a user have been closed, the open session to the user will be
/// closed, and any new data from this user will trigger a /// closed, and any new data from this user will trigger a
/// SteamSteamNetworkingMessagesSessionRequest_t callback /// SteamSteamNetworkingMessagesSessionRequest_t callback
virtual bool CloseChannelWithUser( const SteamNetworkingIdentity &identityRemote, int nLocalChannel ) = 0; virtual bool CloseChannelWithUser(const SteamNetworkingIdentity& identityRemote, int nLocalChannel) = 0;
/// Returns information about the latest state of a connection, if any, with the given peer. /// Returns information about the latest state of a connection, if any, with the given peer.
/// Primarily intended for debugging purposes, but can also be used to get more detailed /// Primarily intended for debugging purposes, but can also be used to get more detailed
/// failure information. (See SendMessageToUser and k_nSteamNetworkingSend_AutoRestartBrokenSession.) /// failure information. (See SendMessageToUser and k_nSteamNetworkingSend_AutoRestartBrokenSession.)
/// ///
/// Returns the value of SteamNetConnectionInfo_t::m_eState, or k_ESteamNetworkingConnectionState_None /// Returns the value of SteamNetConnectionInfo_t::m_eState, or k_ESteamNetworkingConnectionState_None
/// if no connection exists with specified peer. You may pass nullptr for either parameter if /// if no connection exists with specified peer. You may pass nullptr for either parameter if
/// you do not need the corresponding details. Note that sessions time out after a while, /// you do not need the corresponding details. Note that sessions time out after a while,
/// so if a connection fails, or SendMessageToUser returns k_EResultNoConnection, you cannot wait /// so if a connection fails, or SendMessageToUser returns k_EResultNoConnection, you cannot wait
/// indefinitely to obtain the reason for failure. /// indefinitely to obtain the reason for failure.
virtual ESteamNetworkingConnectionState GetSessionConnectionInfo( const SteamNetworkingIdentity &identityRemote, SteamNetConnectionInfo_t *pConnectionInfo, SteamNetworkingQuickConnectionStatus *pQuickStatus ) = 0; virtual ESteamNetworkingConnectionState GetSessionConnectionInfo(const SteamNetworkingIdentity& identityRemote, SteamNetConnectionInfo_t* pConnectionInfo, SteamNetworkingQuickConnectionStatus* pQuickStatus) = 0;
}; };
#define STEAMNETWORKINGMESSAGES_INTERFACE_VERSION "SteamNetworkingMessages002" #define STEAMNETWORKINGMESSAGES_INTERFACE_VERSION "SteamNetworkingMessages002"
@ -128,13 +127,12 @@ public:
// Callbacks // Callbacks
// //
#pragma pack( push, 1 ) #pragma pack(push, 1)
/// Posted when a remote host is sending us a message, and we do not already have a session with them /// Posted when a remote host is sending us a message, and we do not already have a session with them
struct SteamNetworkingMessagesSessionRequest_t struct SteamNetworkingMessagesSessionRequest_t {
{ enum { k_iCallback = k_iSteamNetworkingMessagesCallbacks + 1 };
enum { k_iCallback = k_iSteamNetworkingMessagesCallbacks + 1 }; SteamNetworkingIdentity m_identityRemote; // user who wants to talk to us
SteamNetworkingIdentity m_identityRemote; // user who wants to talk to us
}; };
/// Posted when we fail to establish a connection, or we detect that communications /// Posted when we fail to establish a connection, or we detect that communications
@ -148,14 +146,13 @@ struct SteamNetworkingMessagesSessionRequest_t
/// Also, if a session times out due to inactivity, no callbacks will be posted. The only /// Also, if a session times out due to inactivity, no callbacks will be posted. The only
/// way to detect that this is happening is that querying the session state may return /// way to detect that this is happening is that querying the session state may return
/// none, connecting, and findingroute again. /// none, connecting, and findingroute again.
struct SteamNetworkingMessagesSessionFailed_t struct SteamNetworkingMessagesSessionFailed_t {
{ enum { k_iCallback = k_iSteamNetworkingMessagesCallbacks + 2 };
enum { k_iCallback = k_iSteamNetworkingMessagesCallbacks + 2 };
/// Detailed info about the session that failed. /// Detailed info about the session that failed.
/// SteamNetConnectionInfo_t::m_identityRemote indicates who this session /// SteamNetConnectionInfo_t::m_identityRemote indicates who this session
/// was with. /// was with.
SteamNetConnectionInfo_t m_info; SteamNetConnectionInfo_t m_info;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -164,36 +161,45 @@ struct SteamNetworkingMessagesSessionFailed_t
// Using standalone lib // Using standalone lib
#ifdef STEAMNETWORKINGSOCKETS_STANDALONELIB #ifdef STEAMNETWORKINGSOCKETS_STANDALONELIB
// Standalone lib. // Standalone lib.
static_assert( STEAMNETWORKINGMESSAGES_INTERFACE_VERSION[25] == '2', "Version mismatch" ); static_assert(STEAMNETWORKINGMESSAGES_INTERFACE_VERSION[25] == '2', "Version mismatch");
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingMessages *SteamNetworkingMessages_LibV2(); STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingMessages* SteamNetworkingMessages_LibV2();
inline ISteamNetworkingMessages *SteamNetworkingMessages_Lib() { return SteamNetworkingMessages_LibV2(); } inline ISteamNetworkingMessages* SteamNetworkingMessages_Lib() { return SteamNetworkingMessages_LibV2(); }
// If running in context of steam, we also define a gameserver instance. // If running in context of steam, we also define a gameserver instance.
#ifdef STEAMNETWORKINGSOCKETS_STEAM #ifdef STEAMNETWORKINGSOCKETS_STEAM
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingMessages *SteamGameServerNetworkingMessages_LibV2(); STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingMessages* SteamGameServerNetworkingMessages_LibV2();
inline ISteamNetworkingMessages *SteamGameServerNetworkingMessages_Lib() { return SteamGameServerNetworkingMessages_LibV2(); } inline ISteamNetworkingMessages* SteamGameServerNetworkingMessages_Lib() { return SteamGameServerNetworkingMessages_LibV2(); }
#endif #endif
#ifndef STEAMNETWORKINGSOCKETS_STEAMAPI #ifndef STEAMNETWORKINGSOCKETS_STEAMAPI
inline ISteamNetworkingMessages *SteamNetworkingMessages() { return SteamNetworkingMessages_LibV2(); } inline ISteamNetworkingMessages* SteamNetworkingMessages()
#ifdef STEAMNETWORKINGSOCKETS_STEAM {
inline ISteamNetworkingMessages *SteamGameServerNetworkingMessages() { return SteamGameServerNetworkingMessages_LibV2(); } return SteamNetworkingMessages_LibV2();
#endif }
#endif #ifdef STEAMNETWORKINGSOCKETS_STEAM
inline ISteamNetworkingMessages* SteamGameServerNetworkingMessages()
{
return SteamGameServerNetworkingMessages_LibV2();
}
#endif
#endif
#endif #endif
// Using Steamworks SDK // Using Steamworks SDK
#ifdef STEAMNETWORKINGSOCKETS_STEAMAPI #ifdef STEAMNETWORKINGSOCKETS_STEAMAPI
// Steamworks SDK // Steamworks SDK
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamNetworkingMessages *, SteamNetworkingMessages_SteamAPI, STEAMNETWORKINGMESSAGES_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamNetworkingMessages*, SteamNetworkingMessages_SteamAPI, STEAMNETWORKINGMESSAGES_INTERFACE_VERSION);
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamNetworkingMessages *, SteamGameServerNetworkingMessages_SteamAPI, STEAMNETWORKINGMESSAGES_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamNetworkingMessages*, SteamGameServerNetworkingMessages_SteamAPI, STEAMNETWORKINGMESSAGES_INTERFACE_VERSION);
#ifndef STEAMNETWORKINGSOCKETS_STANDALONELIB #ifndef STEAMNETWORKINGSOCKETS_STANDALONELIB
inline ISteamNetworkingMessages *SteamNetworkingMessages() { return SteamNetworkingMessages_SteamAPI(); } inline ISteamNetworkingMessages* SteamNetworkingMessages()
inline ISteamNetworkingMessages *SteamGameServerNetworkingMessages() { return SteamGameServerNetworkingMessages_SteamAPI(); } {
#endif return SteamNetworkingMessages_SteamAPI();
}
inline ISteamNetworkingMessages* SteamGameServerNetworkingMessages() { return SteamGameServerNetworkingMessages_SteamAPI(); }
#endif
#endif #endif
#endif // ISTEAMNETWORKINGMESSAGES #endif // ISTEAMNETWORKINGMESSAGES

View File

@ -8,8 +8,8 @@
#define ISTEAMNETWORKINGUTILS #define ISTEAMNETWORKINGUTILS
#pragma once #pragma once
#include "steamnetworkingtypes.h"
#include "steam_api_common.h" #include "steam_api_common.h"
#include "steamnetworkingtypes.h"
struct SteamDatagramRelayAuthTicket; struct SteamDatagramRelayAuthTicket;
struct SteamRelayNetworkStatus_t; struct SteamRelayNetworkStatus_t;
@ -17,305 +17,306 @@ struct SteamRelayNetworkStatus_t;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// Misc networking utilities for checking the local networking environment /// Misc networking utilities for checking the local networking environment
/// and estimating pings. /// and estimating pings.
class ISteamNetworkingUtils class ISteamNetworkingUtils {
{
public: public:
// //
// Efficient message sending // Efficient message sending
// //
/// Allocate and initialize a message object. Usually the reason /// Allocate and initialize a message object. Usually the reason
/// you call this is to pass it to ISteamNetworkingSockets::SendMessages. /// you call this is to pass it to ISteamNetworkingSockets::SendMessages.
/// The returned object will have all of the relevant fields cleared to zero. /// The returned object will have all of the relevant fields cleared to zero.
/// ///
/// Optionally you can also request that this system allocate space to /// Optionally you can also request that this system allocate space to
/// hold the payload itself. If cbAllocateBuffer is nonzero, the system /// hold the payload itself. If cbAllocateBuffer is nonzero, the system
/// will allocate memory to hold a payload of at least cbAllocateBuffer bytes. /// will allocate memory to hold a payload of at least cbAllocateBuffer bytes.
/// m_pData will point to the allocated buffer, m_cbSize will be set to the /// m_pData will point to the allocated buffer, m_cbSize will be set to the
/// size, and m_pfnFreeData will be set to the proper function to free up /// size, and m_pfnFreeData will be set to the proper function to free up
/// the buffer. /// the buffer.
/// ///
/// If cbAllocateBuffer=0, then no buffer is allocated. m_pData will be NULL, /// If cbAllocateBuffer=0, then no buffer is allocated. m_pData will be NULL,
/// m_cbSize will be zero, and m_pfnFreeData will be NULL. You will need to /// m_cbSize will be zero, and m_pfnFreeData will be NULL. You will need to
/// set each of these. /// set each of these.
virtual SteamNetworkingMessage_t *AllocateMessage( int cbAllocateBuffer ) = 0; virtual SteamNetworkingMessage_t* AllocateMessage(int cbAllocateBuffer) = 0;
// //
// Access to Steam Datagram Relay (SDR) network // Access to Steam Datagram Relay (SDR) network
// //
// //
// Initialization and status check // Initialization and status check
// //
/// If you know that you are going to be using the relay network (for example, /// If you know that you are going to be using the relay network (for example,
/// because you anticipate making P2P connections), call this to initialize the /// because you anticipate making P2P connections), call this to initialize the
/// relay network. If you do not call this, the initialization will /// relay network. If you do not call this, the initialization will
/// be delayed until the first time you use a feature that requires access /// be delayed until the first time you use a feature that requires access
/// to the relay network, which will delay that first access. /// to the relay network, which will delay that first access.
/// ///
/// You can also call this to force a retry if the previous attempt has failed. /// You can also call this to force a retry if the previous attempt has failed.
/// Performing any action that requires access to the relay network will also /// Performing any action that requires access to the relay network will also
/// trigger a retry, and so calling this function is never strictly necessary, /// trigger a retry, and so calling this function is never strictly necessary,
/// but it can be useful to call it a program launch time, if access to the /// but it can be useful to call it a program launch time, if access to the
/// relay network is anticipated. /// relay network is anticipated.
/// ///
/// Use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t /// Use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t
/// callbacks to know when initialization has completed. /// callbacks to know when initialization has completed.
/// Typically initialization completes in a few seconds. /// Typically initialization completes in a few seconds.
/// ///
/// Note: dedicated servers hosted in known data centers do *not* need /// Note: dedicated servers hosted in known data centers do *not* need
/// to call this, since they do not make routing decisions. However, if /// to call this, since they do not make routing decisions. However, if
/// the dedicated server will be using P2P functionality, it will act as /// the dedicated server will be using P2P functionality, it will act as
/// a "client" and this should be called. /// a "client" and this should be called.
inline void InitRelayNetworkAccess(); inline void InitRelayNetworkAccess();
/// Fetch current status of the relay network. /// Fetch current status of the relay network.
/// ///
/// SteamRelayNetworkStatus_t is also a callback. It will be triggered on /// SteamRelayNetworkStatus_t is also a callback. It will be triggered on
/// both the user and gameserver interfaces any time the status changes, or /// both the user and gameserver interfaces any time the status changes, or
/// ping measurement starts or stops. /// ping measurement starts or stops.
/// ///
/// SteamRelayNetworkStatus_t::m_eAvail is returned. If you want /// SteamRelayNetworkStatus_t::m_eAvail is returned. If you want
/// more details, you can pass a non-NULL value. /// more details, you can pass a non-NULL value.
virtual ESteamNetworkingAvailability GetRelayNetworkStatus( SteamRelayNetworkStatus_t *pDetails ) = 0; virtual ESteamNetworkingAvailability GetRelayNetworkStatus(SteamRelayNetworkStatus_t* pDetails) = 0;
// //
// "Ping location" functions // "Ping location" functions
// //
// We use the ping times to the valve relays deployed worldwide to // We use the ping times to the valve relays deployed worldwide to
// generate a "marker" that describes the location of an Internet host. // generate a "marker" that describes the location of an Internet host.
// Given two such markers, we can estimate the network latency between // Given two such markers, we can estimate the network latency between
// two hosts, without sending any packets. The estimate is based on the // two hosts, without sending any packets. The estimate is based on the
// optimal route that is found through the Valve network. If you are // optimal route that is found through the Valve network. If you are
// using the Valve network to carry the traffic, then this is precisely // using the Valve network to carry the traffic, then this is precisely
// the ping you want. If you are not, then the ping time will probably // the ping you want. If you are not, then the ping time will probably
// still be a reasonable estimate. // still be a reasonable estimate.
// //
// This is extremely useful to select peers for matchmaking! // This is extremely useful to select peers for matchmaking!
// //
// The markers can also be converted to a string, so they can be transmitted. // The markers can also be converted to a string, so they can be transmitted.
// We have a separate library you can use on your app's matchmaking/coordinating // We have a separate library you can use on your app's matchmaking/coordinating
// server to manipulate these objects. (See steamdatagram_gamecoordinator.h) // server to manipulate these objects. (See steamdatagram_gamecoordinator.h)
/// Return location info for the current host. Returns the approximate /// Return location info for the current host. Returns the approximate
/// age of the data, in seconds, or -1 if no data is available. /// age of the data, in seconds, or -1 if no data is available.
/// ///
/// It takes a few seconds to initialize access to the relay network. If /// It takes a few seconds to initialize access to the relay network. If
/// you call this very soon after calling InitRelayNetworkAccess, /// you call this very soon after calling InitRelayNetworkAccess,
/// the data may not be available yet. /// the data may not be available yet.
/// ///
/// This always return the most up-to-date information we have available /// This always return the most up-to-date information we have available
/// right now, even if we are in the middle of re-calculating ping times. /// right now, even if we are in the middle of re-calculating ping times.
virtual float GetLocalPingLocation( SteamNetworkPingLocation_t &result ) = 0; virtual float GetLocalPingLocation(SteamNetworkPingLocation_t& result) = 0;
/// Estimate the round-trip latency between two arbitrary locations, in /// Estimate the round-trip latency between two arbitrary locations, in
/// milliseconds. This is a conservative estimate, based on routing through /// milliseconds. This is a conservative estimate, based on routing through
/// the relay network. For most basic relayed connections, this ping time /// the relay network. For most basic relayed connections, this ping time
/// will be pretty accurate, since it will be based on the route likely to /// will be pretty accurate, since it will be based on the route likely to
/// be actually used. /// be actually used.
/// ///
/// If a direct IP route is used (perhaps via NAT traversal), then the route /// If a direct IP route is used (perhaps via NAT traversal), then the route
/// will be different, and the ping time might be better. Or it might actually /// will be different, and the ping time might be better. Or it might actually
/// be a bit worse! Standard IP routing is frequently suboptimal! /// be a bit worse! Standard IP routing is frequently suboptimal!
/// ///
/// But even in this case, the estimate obtained using this method is a /// But even in this case, the estimate obtained using this method is a
/// reasonable upper bound on the ping time. (Also it has the advantage /// reasonable upper bound on the ping time. (Also it has the advantage
/// of returning immediately and not sending any packets.) /// of returning immediately and not sending any packets.)
/// ///
/// In a few cases we might not able to estimate the route. In this case /// In a few cases we might not able to estimate the route. In this case
/// a negative value is returned. k_nSteamNetworkingPing_Failed means /// a negative value is returned. k_nSteamNetworkingPing_Failed means
/// the reason was because of some networking difficulty. (Failure to /// the reason was because of some networking difficulty. (Failure to
/// ping, etc) k_nSteamNetworkingPing_Unknown is returned if we cannot /// ping, etc) k_nSteamNetworkingPing_Unknown is returned if we cannot
/// currently answer the question for some other reason. /// currently answer the question for some other reason.
/// ///
/// Do you need to be able to do this from a backend/matchmaking server? /// Do you need to be able to do this from a backend/matchmaking server?
/// You are looking for the "ticketgen" library. /// You are looking for the "ticketgen" library.
virtual int EstimatePingTimeBetweenTwoLocations( const SteamNetworkPingLocation_t &location1, const SteamNetworkPingLocation_t &location2 ) = 0; virtual int EstimatePingTimeBetweenTwoLocations(const SteamNetworkPingLocation_t& location1, const SteamNetworkPingLocation_t& location2) = 0;
/// Same as EstimatePingTime, but assumes that one location is the local host. /// Same as EstimatePingTime, but assumes that one location is the local host.
/// This is a bit faster, especially if you need to calculate a bunch of /// This is a bit faster, especially if you need to calculate a bunch of
/// these in a loop to find the fastest one. /// these in a loop to find the fastest one.
/// ///
/// In rare cases this might return a slightly different estimate than combining /// In rare cases this might return a slightly different estimate than combining
/// GetLocalPingLocation with EstimatePingTimeBetweenTwoLocations. That's because /// GetLocalPingLocation with EstimatePingTimeBetweenTwoLocations. That's because
/// this function uses a slightly more complete set of information about what /// this function uses a slightly more complete set of information about what
/// route would be taken. /// route would be taken.
virtual int EstimatePingTimeFromLocalHost( const SteamNetworkPingLocation_t &remoteLocation ) = 0; virtual int EstimatePingTimeFromLocalHost(const SteamNetworkPingLocation_t& remoteLocation) = 0;
/// Convert a ping location into a text format suitable for sending over the wire. /// Convert a ping location into a text format suitable for sending over the wire.
/// The format is a compact and human readable. However, it is subject to change /// The format is a compact and human readable. However, it is subject to change
/// so please do not parse it yourself. Your buffer must be at least /// so please do not parse it yourself. Your buffer must be at least
/// k_cchMaxSteamNetworkingPingLocationString bytes. /// k_cchMaxSteamNetworkingPingLocationString bytes.
virtual void ConvertPingLocationToString( const SteamNetworkPingLocation_t &location, char *pszBuf, int cchBufSize ) = 0; virtual void ConvertPingLocationToString(const SteamNetworkPingLocation_t& location, char* pszBuf, int cchBufSize) = 0;
/// Parse back SteamNetworkPingLocation_t string. Returns false if we couldn't understand /// Parse back SteamNetworkPingLocation_t string. Returns false if we couldn't understand
/// the string. /// the string.
virtual bool ParsePingLocationString( const char *pszString, SteamNetworkPingLocation_t &result ) = 0; virtual bool ParsePingLocationString(const char* pszString, SteamNetworkPingLocation_t& result) = 0;
/// Check if the ping data of sufficient recency is available, and if /// Check if the ping data of sufficient recency is available, and if
/// it's too old, start refreshing it. /// it's too old, start refreshing it.
/// ///
/// Please only call this function when you *really* do need to force an /// Please only call this function when you *really* do need to force an
/// immediate refresh of the data. (For example, in response to a specific /// immediate refresh of the data. (For example, in response to a specific
/// user input to refresh this information.) Don't call it "just in case", /// user input to refresh this information.) Don't call it "just in case",
/// before every connection, etc. That will cause extra traffic to be sent /// before every connection, etc. That will cause extra traffic to be sent
/// for no benefit. The library will automatically refresh the information /// for no benefit. The library will automatically refresh the information
/// as needed. /// as needed.
/// ///
/// Returns true if sufficiently recent data is already available. /// Returns true if sufficiently recent data is already available.
/// ///
/// Returns false if sufficiently recent data is not available. In this /// Returns false if sufficiently recent data is not available. In this
/// case, ping measurement is initiated, if it is not already active. /// case, ping measurement is initiated, if it is not already active.
/// (You cannot restart a measurement already in progress.) /// (You cannot restart a measurement already in progress.)
/// ///
/// You can use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t /// You can use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t
/// to know when ping measurement completes. /// to know when ping measurement completes.
virtual bool CheckPingDataUpToDate( float flMaxAgeSeconds ) = 0; virtual bool CheckPingDataUpToDate(float flMaxAgeSeconds) = 0;
// //
// List of Valve data centers, and ping times to them. This might // List of Valve data centers, and ping times to them. This might
// be useful to you if you are use our hosting, or just need to measure // be useful to you if you are use our hosting, or just need to measure
// latency to a cloud data center where we are running relays. // latency to a cloud data center where we are running relays.
// //
/// Fetch ping time of best available relayed route from this host to /// Fetch ping time of best available relayed route from this host to
/// the specified data center. /// the specified data center.
virtual int GetPingToDataCenter( SteamNetworkingPOPID popID, SteamNetworkingPOPID *pViaRelayPoP ) = 0; virtual int GetPingToDataCenter(SteamNetworkingPOPID popID, SteamNetworkingPOPID* pViaRelayPoP) = 0;
/// Get *direct* ping time to the relays at the data center. /// Get *direct* ping time to the relays at the data center.
virtual int GetDirectPingToPOP( SteamNetworkingPOPID popID ) = 0; virtual int GetDirectPingToPOP(SteamNetworkingPOPID popID) = 0;
/// Get number of network points of presence in the config /// Get number of network points of presence in the config
virtual int GetPOPCount() = 0; virtual int GetPOPCount() = 0;
/// Get list of all POP IDs. Returns the number of entries that were filled into /// Get list of all POP IDs. Returns the number of entries that were filled into
/// your list. /// your list.
virtual int GetPOPList( SteamNetworkingPOPID *list, int nListSz ) = 0; virtual int GetPOPList(SteamNetworkingPOPID* list, int nListSz) = 0;
// //
// Misc // Misc
// //
/// Fetch current timestamp. This timer has the following properties: /// Fetch current timestamp. This timer has the following properties:
/// ///
/// - Monotonicity is guaranteed. /// - Monotonicity is guaranteed.
/// - The initial value will be at least 24*3600*30*1e6, i.e. about /// - The initial value will be at least 24*3600*30*1e6, i.e. about
/// 30 days worth of microseconds. In this way, the timestamp value of /// 30 days worth of microseconds. In this way, the timestamp value of
/// 0 will always be at least "30 days ago". Also, negative numbers /// 0 will always be at least "30 days ago". Also, negative numbers
/// will never be returned. /// will never be returned.
/// - Wraparound / overflow is not a practical concern. /// - Wraparound / overflow is not a practical concern.
/// ///
/// If you are running under the debugger and stop the process, the clock /// If you are running under the debugger and stop the process, the clock
/// might not advance the full wall clock time that has elapsed between /// might not advance the full wall clock time that has elapsed between
/// calls. If the process is not blocked from normal operation, the /// calls. If the process is not blocked from normal operation, the
/// timestamp values will track wall clock time, even if you don't call /// timestamp values will track wall clock time, even if you don't call
/// the function frequently. /// the function frequently.
/// ///
/// The value is only meaningful for this run of the process. Don't compare /// The value is only meaningful for this run of the process. Don't compare
/// it to values obtained on another computer, or other runs of the same process. /// it to values obtained on another computer, or other runs of the same process.
virtual SteamNetworkingMicroseconds GetLocalTimestamp() = 0; virtual SteamNetworkingMicroseconds GetLocalTimestamp() = 0;
/// Set a function to receive network-related information that is useful for debugging. /// Set a function to receive network-related information that is useful for debugging.
/// This can be very useful during development, but it can also be useful for troubleshooting /// This can be very useful during development, but it can also be useful for troubleshooting
/// problems with tech savvy end users. If you have a console or other log that customers /// problems with tech savvy end users. If you have a console or other log that customers
/// can examine, these log messages can often be helpful to troubleshoot network issues. /// can examine, these log messages can often be helpful to troubleshoot network issues.
/// (Especially any warning/error messages.) /// (Especially any warning/error messages.)
/// ///
/// The detail level indicates what message to invoke your callback on. Lower numeric /// The detail level indicates what message to invoke your callback on. Lower numeric
/// value means more important, and the value you pass is the lowest priority (highest /// value means more important, and the value you pass is the lowest priority (highest
/// numeric value) you wish to receive callbacks for. /// numeric value) you wish to receive callbacks for.
/// ///
/// The value here controls the detail level for most messages. You can control the /// The value here controls the detail level for most messages. You can control the
/// detail level for various subsystems (perhaps only for certain connections) by /// detail level for various subsystems (perhaps only for certain connections) by
/// adjusting the configuration values k_ESteamNetworkingConfig_LogLevel_Xxxxx. /// adjusting the configuration values k_ESteamNetworkingConfig_LogLevel_Xxxxx.
/// ///
/// Except when debugging, you should only use k_ESteamNetworkingSocketsDebugOutputType_Msg /// Except when debugging, you should only use k_ESteamNetworkingSocketsDebugOutputType_Msg
/// or k_ESteamNetworkingSocketsDebugOutputType_Warning. For best performance, do NOT /// or k_ESteamNetworkingSocketsDebugOutputType_Warning. For best performance, do NOT
/// request a high detail level and then filter out messages in your callback. This incurs /// request a high detail level and then filter out messages in your callback. This incurs
/// all of the expense of formatting the messages, which are then discarded. Setting a high /// all of the expense of formatting the messages, which are then discarded. Setting a high
/// priority value (low numeric value) here allows the library to avoid doing this work. /// priority value (low numeric value) here allows the library to avoid doing this work.
/// ///
/// IMPORTANT: This may be called from a service thread, while we own a mutex, etc. /// IMPORTANT: This may be called from a service thread, while we own a mutex, etc.
/// Your output function must be threadsafe and fast! Do not make any other /// Your output function must be threadsafe and fast! Do not make any other
/// Steamworks calls from within the handler. /// Steamworks calls from within the handler.
virtual void SetDebugOutputFunction( ESteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc ) = 0; virtual void SetDebugOutputFunction(ESteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc) = 0;
// //
// Set and get configuration values, see ESteamNetworkingConfigValue for individual descriptions. // Set and get configuration values, see ESteamNetworkingConfigValue for individual descriptions.
// //
// Shortcuts for common cases. (Implemented as inline functions below) // Shortcuts for common cases. (Implemented as inline functions below)
bool SetGlobalConfigValueInt32( ESteamNetworkingConfigValue eValue, int32 val ); bool SetGlobalConfigValueInt32(ESteamNetworkingConfigValue eValue, int32 val);
bool SetGlobalConfigValueFloat( ESteamNetworkingConfigValue eValue, float val ); bool SetGlobalConfigValueFloat(ESteamNetworkingConfigValue eValue, float val);
bool SetGlobalConfigValueString( ESteamNetworkingConfigValue eValue, const char *val ); bool SetGlobalConfigValueString(ESteamNetworkingConfigValue eValue, const char* val);
bool SetGlobalConfigValuePtr( ESteamNetworkingConfigValue eValue, void *val ); bool SetGlobalConfigValuePtr(ESteamNetworkingConfigValue eValue, void* val);
bool SetConnectionConfigValueInt32( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, int32 val ); bool SetConnectionConfigValueInt32(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, int32 val);
bool SetConnectionConfigValueFloat( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val ); bool SetConnectionConfigValueFloat(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val);
bool SetConnectionConfigValueString( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char *val ); bool SetConnectionConfigValueString(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char* val);
// //
// Set global callbacks. If you do not want to use Steam's callback dispatch mechanism and you // Set global callbacks. If you do not want to use Steam's callback dispatch mechanism and you
// want to use the same callback on all (or most) listen sockets and connections, then // want to use the same callback on all (or most) listen sockets and connections, then
// simply install these callbacks first thing, and you are good to go. // simply install these callbacks first thing, and you are good to go.
// See ISteamNetworkingSockets::RunCallbacks // See ISteamNetworkingSockets::RunCallbacks
// //
bool SetGlobalCallback_SteamNetConnectionStatusChanged( FnSteamNetConnectionStatusChanged fnCallback ); bool SetGlobalCallback_SteamNetConnectionStatusChanged(FnSteamNetConnectionStatusChanged fnCallback);
bool SetGlobalCallback_SteamNetAuthenticationStatusChanged( FnSteamNetAuthenticationStatusChanged fnCallback ); bool SetGlobalCallback_SteamNetAuthenticationStatusChanged(FnSteamNetAuthenticationStatusChanged fnCallback);
bool SetGlobalCallback_SteamRelayNetworkStatusChanged( FnSteamRelayNetworkStatusChanged fnCallback ); bool SetGlobalCallback_SteamRelayNetworkStatusChanged(FnSteamRelayNetworkStatusChanged fnCallback);
bool SetGlobalCallback_MessagesSessionRequest( FnSteamNetworkingMessagesSessionRequest fnCallback ); bool SetGlobalCallback_MessagesSessionRequest(FnSteamNetworkingMessagesSessionRequest fnCallback);
bool SetGlobalCallback_MessagesSessionFailed( FnSteamNetworkingMessagesSessionFailed fnCallback ); bool SetGlobalCallback_MessagesSessionFailed(FnSteamNetworkingMessagesSessionFailed fnCallback);
/// Set a configuration value. /// Set a configuration value.
/// - eValue: which value is being set /// - eValue: which value is being set
/// - eScope: Onto what type of object are you applying the setting? /// - eScope: Onto what type of object are you applying the setting?
/// - scopeArg: Which object you want to change? (Ignored for global scope). E.g. connection handle, listen socket handle, interface pointer, etc. /// - scopeArg: Which object you want to change? (Ignored for global scope). E.g. connection handle, listen socket handle, interface pointer, etc.
/// - eDataType: What type of data is in the buffer at pValue? This must match the type of the variable exactly! /// - eDataType: What type of data is in the buffer at pValue? This must match the type of the variable exactly!
/// - pArg: Value to set it to. You can pass NULL to remove a non-global setting at this scope, /// - pArg: Value to set it to. You can pass NULL to remove a non-global setting at this scope,
/// causing the value for that object to use global defaults. Or at global scope, passing NULL /// causing the value for that object to use global defaults. Or at global scope, passing NULL
/// will reset any custom value and restore it to the system default. /// will reset any custom value and restore it to the system default.
/// NOTE: When setting pointers (e.g. callback functions), do not pass the function pointer directly. /// NOTE: When setting pointers (e.g. callback functions), do not pass the function pointer directly.
/// Your argument should be a pointer to a function pointer. /// Your argument should be a pointer to a function pointer.
virtual bool SetConfigValue( ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj, virtual bool SetConfigValue(ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj,
ESteamNetworkingConfigDataType eDataType, const void *pArg ) = 0; ESteamNetworkingConfigDataType eDataType, const void* pArg)
= 0;
/// Set a configuration value, using a struct to pass the value. /// Set a configuration value, using a struct to pass the value.
/// (This is just a convenience shortcut; see below for the implementation and /// (This is just a convenience shortcut; see below for the implementation and
/// a little insight into how SteamNetworkingConfigValue_t is used when /// a little insight into how SteamNetworkingConfigValue_t is used when
/// setting config options during listen socket and connection creation.) /// setting config options during listen socket and connection creation.)
bool SetConfigValueStruct( const SteamNetworkingConfigValue_t &opt, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj ); bool SetConfigValueStruct(const SteamNetworkingConfigValue_t& opt, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj);
/// Get a configuration value. /// Get a configuration value.
/// - eValue: which value to fetch /// - eValue: which value to fetch
/// - eScopeType: query setting on what type of object /// - eScopeType: query setting on what type of object
/// - eScopeArg: the object to query the setting for /// - eScopeArg: the object to query the setting for
/// - pOutDataType: If non-NULL, the data type of the value is returned. /// - pOutDataType: If non-NULL, the data type of the value is returned.
/// - pResult: Where to put the result. Pass NULL to query the required buffer size. (k_ESteamNetworkingGetConfigValue_BufferTooSmall will be returned.) /// - pResult: Where to put the result. Pass NULL to query the required buffer size. (k_ESteamNetworkingGetConfigValue_BufferTooSmall will be returned.)
/// - cbResult: IN: the size of your buffer. OUT: the number of bytes filled in or required. /// - cbResult: IN: the size of your buffer. OUT: the number of bytes filled in or required.
virtual ESteamNetworkingGetConfigValueResult GetConfigValue( ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj, virtual ESteamNetworkingGetConfigValueResult GetConfigValue(ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj,
ESteamNetworkingConfigDataType *pOutDataType, void *pResult, size_t *cbResult ) = 0; ESteamNetworkingConfigDataType* pOutDataType, void* pResult, size_t* cbResult)
= 0;
/// Returns info about a configuration value. Returns false if the value does not exist. /// Returns info about a configuration value. Returns false if the value does not exist.
/// pOutNextValue can be used to iterate through all of the known configuration values. /// pOutNextValue can be used to iterate through all of the known configuration values.
/// (Use GetFirstConfigValue() to begin the iteration, will be k_ESteamNetworkingConfig_Invalid on the last value) /// (Use GetFirstConfigValue() to begin the iteration, will be k_ESteamNetworkingConfig_Invalid on the last value)
/// Any of the output parameters can be NULL if you do not need that information. /// Any of the output parameters can be NULL if you do not need that information.
/// ///
/// See k_ESteamNetworkingConfig_EnumerateDevVars for some more info about "dev" variables, /// See k_ESteamNetworkingConfig_EnumerateDevVars for some more info about "dev" variables,
/// which are usually excluded from the set of variables enumerated using this function. /// which are usually excluded from the set of variables enumerated using this function.
virtual bool GetConfigValueInfo( ESteamNetworkingConfigValue eValue, const char **pOutName, ESteamNetworkingConfigDataType *pOutDataType, ESteamNetworkingConfigScope *pOutScope, ESteamNetworkingConfigValue *pOutNextValue ) = 0; virtual bool GetConfigValueInfo(ESteamNetworkingConfigValue eValue, const char** pOutName, ESteamNetworkingConfigDataType* pOutDataType, ESteamNetworkingConfigScope* pOutScope, ESteamNetworkingConfigValue* pOutNextValue) = 0;
/// Return the lowest numbered configuration value available in the current environment. /// Return the lowest numbered configuration value available in the current environment.
virtual ESteamNetworkingConfigValue GetFirstConfigValue() = 0; virtual ESteamNetworkingConfigValue GetFirstConfigValue() = 0;
// String conversions. You'll usually access these using the respective // String conversions. You'll usually access these using the respective
// inline methods. // inline methods.
virtual void SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr &addr, char *buf, size_t cbBuf, bool bWithPort ) = 0; virtual void SteamNetworkingIPAddr_ToString(const SteamNetworkingIPAddr& addr, char* buf, size_t cbBuf, bool bWithPort) = 0;
virtual bool SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr ) = 0; virtual bool SteamNetworkingIPAddr_ParseString(SteamNetworkingIPAddr* pAddr, const char* pszStr) = 0;
virtual void SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf ) = 0; virtual void SteamNetworkingIdentity_ToString(const SteamNetworkingIdentity& identity, char* buf, size_t cbBuf) = 0;
virtual bool SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, const char *pszStr ) = 0; virtual bool SteamNetworkingIdentity_ParseString(SteamNetworkingIdentity* pIdentity, const char* pszStr) = 0;
protected: protected:
~ISteamNetworkingUtils(); // Silence some warnings ~ISteamNetworkingUtils(); // Silence some warnings
}; };
#define STEAMNETWORKINGUTILS_INTERFACE_VERSION "SteamNetworkingUtils003" #define STEAMNETWORKINGUTILS_INTERFACE_VERSION "SteamNetworkingUtils003"
@ -323,136 +324,138 @@ protected:
// Using standalone lib // Using standalone lib
#ifdef STEAMNETWORKINGSOCKETS_STANDALONELIB #ifdef STEAMNETWORKINGSOCKETS_STANDALONELIB
// Standalone lib // Standalone lib
static_assert( STEAMNETWORKINGUTILS_INTERFACE_VERSION[22] == '3', "Version mismatch" ); static_assert(STEAMNETWORKINGUTILS_INTERFACE_VERSION[22] == '3', "Version mismatch");
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingUtils *SteamNetworkingUtils_LibV3(); STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingUtils* SteamNetworkingUtils_LibV3();
inline ISteamNetworkingUtils *SteamNetworkingUtils_Lib() { return SteamNetworkingUtils_LibV3(); } inline ISteamNetworkingUtils* SteamNetworkingUtils_Lib() { return SteamNetworkingUtils_LibV3(); }
#ifndef STEAMNETWORKINGSOCKETS_STEAMAPI #ifndef STEAMNETWORKINGSOCKETS_STEAMAPI
inline ISteamNetworkingUtils *SteamNetworkingUtils() { return SteamNetworkingUtils_LibV3(); } inline ISteamNetworkingUtils* SteamNetworkingUtils()
#endif {
return SteamNetworkingUtils_LibV3();
}
#endif
#endif #endif
// Using Steamworks SDK // Using Steamworks SDK
#ifdef STEAMNETWORKINGSOCKETS_STEAMAPI #ifdef STEAMNETWORKINGSOCKETS_STEAMAPI
STEAM_DEFINE_INTERFACE_ACCESSOR( ISteamNetworkingUtils *, SteamNetworkingUtils_SteamAPI, STEAM_DEFINE_INTERFACE_ACCESSOR(ISteamNetworkingUtils*, SteamNetworkingUtils_SteamAPI,
/* Prefer user version of the interface. But if it isn't found, then use /* Prefer user version of the interface. But if it isn't found, then use
gameserver one. Yes, this is a completely terrible hack */ gameserver one. Yes, this is a completely terrible hack */
SteamInternal_FindOrCreateUserInterface( 0, STEAMNETWORKINGUTILS_INTERFACE_VERSION ) ? SteamInternal_FindOrCreateUserInterface(0, STEAMNETWORKINGUTILS_INTERFACE_VERSION) ? SteamInternal_FindOrCreateUserInterface(0, STEAMNETWORKINGUTILS_INTERFACE_VERSION) : SteamInternal_FindOrCreateGameServerInterface(0, STEAMNETWORKINGUTILS_INTERFACE_VERSION),
SteamInternal_FindOrCreateUserInterface( 0, STEAMNETWORKINGUTILS_INTERFACE_VERSION ) : "global",
SteamInternal_FindOrCreateGameServerInterface( 0, STEAMNETWORKINGUTILS_INTERFACE_VERSION ), STEAMNETWORKINGUTILS_INTERFACE_VERSION)
"global",
STEAMNETWORKINGUTILS_INTERFACE_VERSION
)
#ifndef STEAMNETWORKINGSOCKETS_STANDALONELIB #ifndef STEAMNETWORKINGSOCKETS_STANDALONELIB
inline ISteamNetworkingUtils *SteamNetworkingUtils() { return SteamNetworkingUtils_SteamAPI(); } inline ISteamNetworkingUtils* SteamNetworkingUtils()
#endif {
return SteamNetworkingUtils_SteamAPI();
}
#endif
#endif #endif
/// A struct used to describe our readiness to use the relay network. /// A struct used to describe our readiness to use the relay network.
/// To do this we first need to fetch the network configuration, /// To do this we first need to fetch the network configuration,
/// which describes what POPs are available. /// which describes what POPs are available.
struct SteamRelayNetworkStatus_t struct SteamRelayNetworkStatus_t {
{ enum { k_iCallback = k_iSteamNetworkingUtilsCallbacks + 1 };
enum { k_iCallback = k_iSteamNetworkingUtilsCallbacks + 1 };
/// Summary status. When this is "current", initialization has /// Summary status. When this is "current", initialization has
/// completed. Anything else means you are not ready yet, or /// completed. Anything else means you are not ready yet, or
/// there is a significant problem. /// there is a significant problem.
ESteamNetworkingAvailability m_eAvail; ESteamNetworkingAvailability m_eAvail;
/// Nonzero if latency measurement is in progress (or pending, /// Nonzero if latency measurement is in progress (or pending,
/// awaiting a prerequisite). /// awaiting a prerequisite).
int m_bPingMeasurementInProgress; int m_bPingMeasurementInProgress;
/// Status obtaining the network config. This is a prerequisite /// Status obtaining the network config. This is a prerequisite
/// for relay network access. /// for relay network access.
/// ///
/// Failure to obtain the network config almost always indicates /// Failure to obtain the network config almost always indicates
/// a problem with the local internet connection. /// a problem with the local internet connection.
ESteamNetworkingAvailability m_eAvailNetworkConfig; ESteamNetworkingAvailability m_eAvailNetworkConfig;
/// Current ability to communicate with ANY relay. Note that /// Current ability to communicate with ANY relay. Note that
/// the complete failure to communicate with any relays almost /// the complete failure to communicate with any relays almost
/// always indicates a problem with the local Internet connection. /// always indicates a problem with the local Internet connection.
/// (However, just because you can reach a single relay doesn't /// (However, just because you can reach a single relay doesn't
/// mean that the local connection is in perfect health.) /// mean that the local connection is in perfect health.)
ESteamNetworkingAvailability m_eAvailAnyRelay; ESteamNetworkingAvailability m_eAvailAnyRelay;
/// Non-localized English language status. For diagnostic/debugging /// Non-localized English language status. For diagnostic/debugging
/// purposes only. /// purposes only.
char m_debugMsg[ 256 ]; char m_debugMsg[256];
}; };
/// Utility class for printing a SteamNetworkingIdentity. /// Utility class for printing a SteamNetworkingIdentity.
/// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() ); /// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() );
struct SteamNetworkingIdentityRender struct SteamNetworkingIdentityRender {
{ SteamNetworkingIdentityRender(const SteamNetworkingIdentity& x) { x.ToString(buf, sizeof(buf)); }
SteamNetworkingIdentityRender( const SteamNetworkingIdentity &x ) { x.ToString( buf, sizeof(buf) ); } inline const char* c_str() const { return buf; }
inline const char *c_str() const { return buf; }
private: private:
char buf[ SteamNetworkingIdentity::k_cchMaxString ]; char buf[SteamNetworkingIdentity::k_cchMaxString];
}; };
/// Utility class for printing a SteamNetworkingIPAddrRender. /// Utility class for printing a SteamNetworkingIPAddrRender.
struct SteamNetworkingIPAddrRender struct SteamNetworkingIPAddrRender {
{ SteamNetworkingIPAddrRender(const SteamNetworkingIPAddr& x, bool bWithPort = true) { x.ToString(buf, sizeof(buf), bWithPort); }
SteamNetworkingIPAddrRender( const SteamNetworkingIPAddr &x, bool bWithPort = true ) { x.ToString( buf, sizeof(buf), bWithPort ); } inline const char* c_str() const { return buf; }
inline const char *c_str() const { return buf; }
private: private:
char buf[ SteamNetworkingIPAddr::k_cchMaxString ]; char buf[SteamNetworkingIPAddr::k_cchMaxString];
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Internal stuff // Internal stuff
inline void ISteamNetworkingUtils::InitRelayNetworkAccess() { CheckPingDataUpToDate( 1e10f ); } inline void ISteamNetworkingUtils::InitRelayNetworkAccess() { CheckPingDataUpToDate(1e10f); }
inline bool ISteamNetworkingUtils::SetGlobalConfigValueInt32( ESteamNetworkingConfigValue eValue, int32 val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Int32, &val ); } inline bool ISteamNetworkingUtils::SetGlobalConfigValueInt32(ESteamNetworkingConfigValue eValue, int32 val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Int32, &val); }
inline bool ISteamNetworkingUtils::SetGlobalConfigValueFloat( ESteamNetworkingConfigValue eValue, float val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Float, &val ); } inline bool ISteamNetworkingUtils::SetGlobalConfigValueFloat(ESteamNetworkingConfigValue eValue, float val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Float, &val); }
inline bool ISteamNetworkingUtils::SetGlobalConfigValueString( ESteamNetworkingConfigValue eValue, const char *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_String, val ); } inline bool ISteamNetworkingUtils::SetGlobalConfigValueString(ESteamNetworkingConfigValue eValue, const char* val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_String, val); }
inline bool ISteamNetworkingUtils::SetGlobalConfigValuePtr( ESteamNetworkingConfigValue eValue, void *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Ptr, &val ); } // Note: passing pointer to pointer. inline bool ISteamNetworkingUtils::SetGlobalConfigValuePtr(ESteamNetworkingConfigValue eValue, void* val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Ptr, &val); } // Note: passing pointer to pointer.
inline bool ISteamNetworkingUtils::SetConnectionConfigValueInt32( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, int32 val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Int32, &val ); } inline bool ISteamNetworkingUtils::SetConnectionConfigValueInt32(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, int32 val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Int32, &val); }
inline bool ISteamNetworkingUtils::SetConnectionConfigValueFloat( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Float, &val ); } inline bool ISteamNetworkingUtils::SetConnectionConfigValueFloat(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Float, &val); }
inline bool ISteamNetworkingUtils::SetConnectionConfigValueString( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_String, val ); } inline bool ISteamNetworkingUtils::SetConnectionConfigValueString(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char* val) { return SetConfigValue(eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_String, val); }
inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamNetConnectionStatusChanged( FnSteamNetConnectionStatusChanged fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_ConnectionStatusChanged, (void*)fnCallback ); } inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamNetConnectionStatusChanged(FnSteamNetConnectionStatusChanged fnCallback) { return SetGlobalConfigValuePtr(k_ESteamNetworkingConfig_Callback_ConnectionStatusChanged, (void*)fnCallback); }
inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamNetAuthenticationStatusChanged( FnSteamNetAuthenticationStatusChanged fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_AuthStatusChanged, (void*)fnCallback ); } inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamNetAuthenticationStatusChanged(FnSteamNetAuthenticationStatusChanged fnCallback) { return SetGlobalConfigValuePtr(k_ESteamNetworkingConfig_Callback_AuthStatusChanged, (void*)fnCallback); }
inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamRelayNetworkStatusChanged( FnSteamRelayNetworkStatusChanged fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_RelayNetworkStatusChanged, (void*)fnCallback ); } inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamRelayNetworkStatusChanged(FnSteamRelayNetworkStatusChanged fnCallback) { return SetGlobalConfigValuePtr(k_ESteamNetworkingConfig_Callback_RelayNetworkStatusChanged, (void*)fnCallback); }
inline bool ISteamNetworkingUtils::SetGlobalCallback_MessagesSessionRequest( FnSteamNetworkingMessagesSessionRequest fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_MessagesSessionRequest, (void*)fnCallback ); } inline bool ISteamNetworkingUtils::SetGlobalCallback_MessagesSessionRequest(FnSteamNetworkingMessagesSessionRequest fnCallback) { return SetGlobalConfigValuePtr(k_ESteamNetworkingConfig_Callback_MessagesSessionRequest, (void*)fnCallback); }
inline bool ISteamNetworkingUtils::SetGlobalCallback_MessagesSessionFailed( FnSteamNetworkingMessagesSessionFailed fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_MessagesSessionFailed, (void*)fnCallback ); } inline bool ISteamNetworkingUtils::SetGlobalCallback_MessagesSessionFailed(FnSteamNetworkingMessagesSessionFailed fnCallback) { return SetGlobalConfigValuePtr(k_ESteamNetworkingConfig_Callback_MessagesSessionFailed, (void*)fnCallback); }
inline bool ISteamNetworkingUtils::SetConfigValueStruct( const SteamNetworkingConfigValue_t &opt, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj ) inline bool ISteamNetworkingUtils::SetConfigValueStruct(const SteamNetworkingConfigValue_t& opt, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj)
{ {
// Locate the argument. Strings are a special case, since the // Locate the argument. Strings are a special case, since the
// "value" (the whole string buffer) doesn't fit in the struct // "value" (the whole string buffer) doesn't fit in the struct
// NOTE: for pointer values, we pass a pointer to the pointer, // NOTE: for pointer values, we pass a pointer to the pointer,
// we do not pass the pointer directly. // we do not pass the pointer directly.
const void *pVal = ( opt.m_eDataType == k_ESteamNetworkingConfig_String ) ? (const void *)opt.m_val.m_string : (const void *)&opt.m_val; const void* pVal = (opt.m_eDataType == k_ESteamNetworkingConfig_String) ? (const void*)opt.m_val.m_string : (const void*)&opt.m_val;
return SetConfigValue( opt.m_eValue, eScopeType, scopeObj, opt.m_eDataType, pVal ); return SetConfigValue(opt.m_eValue, eScopeType, scopeObj, opt.m_eDataType, pVal);
} }
// How to get helper functions. // How to get helper functions.
#if defined( STEAMNETWORKINGSOCKETS_STATIC_LINK ) || defined( STEAMNETWORKINGSOCKETS_STANDALONELIB ) #if defined(STEAMNETWORKINGSOCKETS_STATIC_LINK) || defined(STEAMNETWORKINGSOCKETS_STANDALONELIB)
// Call direct to static functions // Call direct to static functions
STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr *pAddr, char *buf, size_t cbBuf, bool bWithPort ); STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIPAddr_ToString(const SteamNetworkingIPAddr* pAddr, char* buf, size_t cbBuf, bool bWithPort);
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr ); STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIPAddr_ParseString(SteamNetworkingIPAddr* pAddr, const char* pszStr);
STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity *pIdentity, char *buf, size_t cbBuf ); STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIdentity_ToString(const SteamNetworkingIdentity* pIdentity, char* buf, size_t cbBuf);
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, size_t sizeofIdentity, const char *pszStr ); STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIdentity_ParseString(SteamNetworkingIdentity* pIdentity, size_t sizeofIdentity, const char* pszStr);
inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamNetworkingIPAddr_ToString( this, buf, cbBuf, bWithPort ); } inline void SteamNetworkingIPAddr::ToString(char* buf, size_t cbBuf, bool bWithPort) const { SteamNetworkingIPAddr_ToString(this, buf, cbBuf, bWithPort); }
inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamNetworkingIPAddr_ParseString( this, pszStr ); } inline bool SteamNetworkingIPAddr::ParseString(const char* pszStr) { return SteamNetworkingIPAddr_ParseString(this, pszStr); }
inline void SteamNetworkingIdentity::ToString( char *buf, size_t cbBuf ) const { SteamNetworkingIdentity_ToString( this, buf, cbBuf ); } inline void SteamNetworkingIdentity::ToString(char* buf, size_t cbBuf) const { SteamNetworkingIdentity_ToString(this, buf, cbBuf); }
inline bool SteamNetworkingIdentity::ParseString( const char *pszStr ) { return SteamNetworkingIdentity_ParseString( this, sizeof(*this), pszStr ); } inline bool SteamNetworkingIdentity::ParseString(const char* pszStr) { return SteamNetworkingIdentity_ParseString(this, sizeof(*this), pszStr); }
#elif defined( STEAMNETWORKINGSOCKETS_STEAMAPI ) #elif defined(STEAMNETWORKINGSOCKETS_STEAMAPI)
// Using steamworks SDK - go through SteamNetworkingUtils() // Using steamworks SDK - go through SteamNetworkingUtils()
inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamNetworkingUtils()->SteamNetworkingIPAddr_ToString( *this, buf, cbBuf, bWithPort ); } inline void SteamNetworkingIPAddr::ToString(char* buf, size_t cbBuf, bool bWithPort) const { SteamNetworkingUtils()->SteamNetworkingIPAddr_ToString(*this, buf, cbBuf, bWithPort); }
inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamNetworkingUtils()->SteamNetworkingIPAddr_ParseString( this, pszStr ); } inline bool SteamNetworkingIPAddr::ParseString(const char* pszStr) { return SteamNetworkingUtils()->SteamNetworkingIPAddr_ParseString(this, pszStr); }
inline void SteamNetworkingIdentity::ToString( char *buf, size_t cbBuf ) const { SteamNetworkingUtils()->SteamNetworkingIdentity_ToString( *this, buf, cbBuf ); } inline void SteamNetworkingIdentity::ToString(char* buf, size_t cbBuf) const { SteamNetworkingUtils()->SteamNetworkingIdentity_ToString(*this, buf, cbBuf); }
inline bool SteamNetworkingIdentity::ParseString( const char *pszStr ) { return SteamNetworkingUtils()->SteamNetworkingIdentity_ParseString( this, pszStr ); } inline bool SteamNetworkingIdentity::ParseString(const char* pszStr) { return SteamNetworkingUtils()->SteamNetworkingIdentity_ParseString(this, pszStr); }
#else #else
#error "Invalid config" #error "Invalid config"
#endif #endif
#endif // ISTEAMNETWORKINGUTILS #endif // ISTEAMNETWORKINGUTILS

View File

@ -13,51 +13,47 @@
#include "steam_api_common.h" #include "steam_api_common.h"
// Feature types for parental settings // Feature types for parental settings
enum EParentalFeature enum EParentalFeature {
{ k_EFeatureInvalid = 0,
k_EFeatureInvalid = 0, k_EFeatureStore = 1,
k_EFeatureStore = 1, k_EFeatureCommunity = 2,
k_EFeatureCommunity = 2, k_EFeatureProfile = 3,
k_EFeatureProfile = 3, k_EFeatureFriends = 4,
k_EFeatureFriends = 4, k_EFeatureNews = 5,
k_EFeatureNews = 5, k_EFeatureTrading = 6,
k_EFeatureTrading = 6, k_EFeatureSettings = 7,
k_EFeatureSettings = 7, k_EFeatureConsole = 8,
k_EFeatureConsole = 8, k_EFeatureBrowser = 9,
k_EFeatureBrowser = 9, k_EFeatureParentalSetup = 10,
k_EFeatureParentalSetup = 10, k_EFeatureLibrary = 11,
k_EFeatureLibrary = 11, k_EFeatureTest = 12,
k_EFeatureTest = 12, k_EFeatureSiteLicense = 13,
k_EFeatureSiteLicense = 13, k_EFeatureMax
k_EFeatureMax
}; };
class ISteamParentalSettings class ISteamParentalSettings {
{
public: public:
virtual bool BIsParentalLockEnabled() = 0; virtual bool BIsParentalLockEnabled() = 0;
virtual bool BIsParentalLockLocked() = 0; virtual bool BIsParentalLockLocked() = 0;
virtual bool BIsAppBlocked( AppId_t nAppID ) = 0; virtual bool BIsAppBlocked(AppId_t nAppID) = 0;
virtual bool BIsAppInBlockList( AppId_t nAppID ) = 0; virtual bool BIsAppInBlockList(AppId_t nAppID) = 0;
virtual bool BIsFeatureBlocked( EParentalFeature eFeature ) = 0; virtual bool BIsFeatureBlocked(EParentalFeature eFeature) = 0;
virtual bool BIsFeatureInBlockList( EParentalFeature eFeature ) = 0; virtual bool BIsFeatureInBlockList(EParentalFeature eFeature) = 0;
}; };
#define STEAMPARENTALSETTINGS_INTERFACE_VERSION "STEAMPARENTALSETTINGS_INTERFACE_VERSION001" #define STEAMPARENTALSETTINGS_INTERFACE_VERSION "STEAMPARENTALSETTINGS_INTERFACE_VERSION001"
// Global interface accessor // Global interface accessor
inline ISteamParentalSettings *SteamParentalSettings(); inline ISteamParentalSettings* SteamParentalSettings();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamParentalSettings *, SteamParentalSettings, STEAMPARENTALSETTINGS_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamParentalSettings*, SteamParentalSettings, STEAMPARENTALSETTINGS_INTERFACE_VERSION);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback for querying UGC // Purpose: Callback for querying UGC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamParentalSettingsChanged_t struct SteamParentalSettingsChanged_t {
{ enum { k_iCallback = k_ISteamParentalSettingsCallbacks + 1 };
enum { k_iCallback = k_ISteamParentalSettingsCallbacks + 1 };
}; };
#endif // ISTEAMPARENTALSETTINGS_H #endif // ISTEAMPARENTALSETTINGS_H

View File

@ -16,76 +16,68 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Enum for supported gradient directions // Purpose: Enum for supported gradient directions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
enum EOverlayGradientDirection enum EOverlayGradientDirection {
{ k_EOverlayGradientHorizontal = 1,
k_EOverlayGradientHorizontal = 1, k_EOverlayGradientVertical = 2,
k_EOverlayGradientVertical = 2, k_EOverlayGradientNone = 3,
k_EOverlayGradientNone = 3,
}; };
// Helpers for fetching individual color components from ARGB packed DWORD colors Steam PS3 overlay renderer uses. // Helpers for fetching individual color components from ARGB packed DWORD colors Steam PS3 overlay renderer uses.
#define STEAM_COLOR_RED( color ) \ #define STEAM_COLOR_RED(color) \
(int)(((color)>>16)&0xff) (int)(((color) >> 16) & 0xff)
#define STEAM_COLOR_GREEN( color ) \ #define STEAM_COLOR_GREEN(color) \
(int)(((color)>>8)&0xff) (int)(((color) >> 8) & 0xff)
#define STEAM_COLOR_BLUE( color ) \ #define STEAM_COLOR_BLUE(color) \
(int)((color)&0xff) (int)((color)&0xff)
#define STEAM_COLOR_ALPHA( color ) \
(int)(((color)>>24)&0xff)
#define STEAM_COLOR_ALPHA(color) \
(int)(((color) >> 24) & 0xff)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Interface the game must expose to Steam for rendering // Purpose: Interface the game must expose to Steam for rendering
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamPS3OverlayRenderHost class ISteamPS3OverlayRenderHost {
{
public: public:
// Interface for game engine to implement which Steam requires to render.
// Interface for game engine to implement which Steam requires to render. // Draw a textured rect. This may use only part of the texture and will pass texture coords, it will also possibly request a gradient and will specify colors for vertexes.
virtual void DrawTexturedRect(int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection) = 0;
// Draw a textured rect. This may use only part of the texture and will pass texture coords, it will also possibly request a gradient and will specify colors for vertexes. // Load a RGBA texture for Steam, or update a previously loaded one. Updates may be partial. You must not evict or remove this texture once Steam has uploaded it.
virtual void DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection ) = 0; virtual void LoadOrUpdateTexture(int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char* pData) = 0;
// Load a RGBA texture for Steam, or update a previously loaded one. Updates may be partial. You must not evict or remove this texture once Steam has uploaded it. // Delete a texture Steam previously uploaded
virtual void LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData ) = 0; virtual void DeleteTexture(int32 iTextureID) = 0;
// Delete a texture Steam previously uploaded // Delete all previously uploaded textures
virtual void DeleteTexture( int32 iTextureID ) = 0; virtual void DeleteAllTextures() = 0;
// Delete all previously uploaded textures
virtual void DeleteAllTextures() = 0;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Interface Steam exposes for the game to tell it when to render, etc. // Purpose: Interface Steam exposes for the game to tell it when to render, etc.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamPS3OverlayRender class ISteamPS3OverlayRender {
{
public: public:
// Call once at startup to initialize the Steam overlay and pass it your host interface ptr
virtual bool BHostInitialize(uint32 unScreenWidth, uint32 unScreenHeight, uint32 unRefreshRate, ISteamPS3OverlayRenderHost* pRenderHost, void* CellFontLib) = 0;
// Call once at startup to initialize the Steam overlay and pass it your host interface ptr // Call this once a frame when you are ready for the Steam overlay to render (ie, right before flipping buffers, after all your rendering)
virtual bool BHostInitialize( uint32 unScreenWidth, uint32 unScreenHeight, uint32 unRefreshRate, ISteamPS3OverlayRenderHost *pRenderHost, void *CellFontLib ) = 0; virtual void Render() = 0;
// Call this once a frame when you are ready for the Steam overlay to render (ie, right before flipping buffers, after all your rendering) // Call this everytime you read input on PS3.
virtual void Render() = 0; //
// If this returns true, then the overlay is active and has consumed the input, your game
// should then ignore all the input until BHandleCellPadData once again returns false, which
// will mean the overlay is deactivated.
virtual bool BHandleCellPadData(const CellPadData& padData) = 0;
// Call this everytime you read input on PS3. // Call this if you detect no controllers connected or that the XMB is intercepting input
// //
// If this returns true, then the overlay is active and has consumed the input, your game // This is important to clear input state for the overlay, so keys left down during XMB activation
// should then ignore all the input until BHandleCellPadData once again returns false, which // are not continued to be processed.
// will mean the overlay is deactivated. virtual bool BResetInputState() = 0;
virtual bool BHandleCellPadData( const CellPadData &padData ) = 0;
// Call this if you detect no controllers connected or that the XMB is intercepting input
//
// This is important to clear input state for the overlay, so keys left down during XMB activation
// are not continued to be processed.
virtual bool BResetInputState() = 0;
}; };
#endif // ISTEAMPS3OVERLAYRENDERER_H #endif // ISTEAMPS3OVERLAYRENDERER_H

View File

@ -8,81 +8,73 @@
#include "steam_api_common.h" #include "steam_api_common.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The form factor of a device // Purpose: The form factor of a device
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
enum ESteamDeviceFormFactor enum ESteamDeviceFormFactor {
{ k_ESteamDeviceFormFactorUnknown = 0,
k_ESteamDeviceFormFactorUnknown = 0, k_ESteamDeviceFormFactorPhone = 1,
k_ESteamDeviceFormFactorPhone = 1, k_ESteamDeviceFormFactorTablet = 2,
k_ESteamDeviceFormFactorTablet = 2, k_ESteamDeviceFormFactorComputer = 3,
k_ESteamDeviceFormFactorComputer = 3, k_ESteamDeviceFormFactorTV = 4,
k_ESteamDeviceFormFactorTV = 4,
}; };
// Steam Remote Play session ID // Steam Remote Play session ID
typedef uint32 RemotePlaySessionID_t; typedef uint32 RemotePlaySessionID_t;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions to provide information about Steam Remote Play sessions // Purpose: Functions to provide information about Steam Remote Play sessions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamRemotePlay class ISteamRemotePlay {
{
public: public:
// Get the number of currently connected Steam Remote Play sessions // Get the number of currently connected Steam Remote Play sessions
virtual uint32 GetSessionCount() = 0; virtual uint32 GetSessionCount() = 0;
// Get the currently connected Steam Remote Play session ID at the specified index. Returns zero if index is out of bounds.
virtual RemotePlaySessionID_t GetSessionID( int iSessionIndex ) = 0;
// Get the SteamID of the connected user // Get the currently connected Steam Remote Play session ID at the specified index. Returns zero if index is out of bounds.
virtual CSteamID GetSessionSteamID( RemotePlaySessionID_t unSessionID ) = 0; virtual RemotePlaySessionID_t GetSessionID(int iSessionIndex) = 0;
// Get the name of the session client device // Get the SteamID of the connected user
// This returns NULL if the sessionID is not valid virtual CSteamID GetSessionSteamID(RemotePlaySessionID_t unSessionID) = 0;
virtual const char *GetSessionClientName( RemotePlaySessionID_t unSessionID ) = 0;
// Get the form factor of the session client device // Get the name of the session client device
virtual ESteamDeviceFormFactor GetSessionClientFormFactor( RemotePlaySessionID_t unSessionID ) = 0; // This returns NULL if the sessionID is not valid
virtual const char* GetSessionClientName(RemotePlaySessionID_t unSessionID) = 0;
// Get the resolution, in pixels, of the session client device // Get the form factor of the session client device
// This is set to 0x0 if the resolution is not available virtual ESteamDeviceFormFactor GetSessionClientFormFactor(RemotePlaySessionID_t unSessionID) = 0;
virtual bool BGetSessionClientResolution( RemotePlaySessionID_t unSessionID, int *pnResolutionX, int *pnResolutionY ) = 0;
// Invite a friend to Remote Play Together // Get the resolution, in pixels, of the session client device
// This returns false if the invite can't be sent // This is set to 0x0 if the resolution is not available
virtual bool BSendRemotePlayTogetherInvite( CSteamID steamIDFriend ) = 0; virtual bool BGetSessionClientResolution(RemotePlaySessionID_t unSessionID, int* pnResolutionX, int* pnResolutionY) = 0;
// Invite a friend to Remote Play Together
// This returns false if the invite can't be sent
virtual bool BSendRemotePlayTogetherInvite(CSteamID steamIDFriend) = 0;
}; };
#define STEAMREMOTEPLAY_INTERFACE_VERSION "STEAMREMOTEPLAY_INTERFACE_VERSION001" #define STEAMREMOTEPLAY_INTERFACE_VERSION "STEAMREMOTEPLAY_INTERFACE_VERSION001"
// Global interface accessor // Global interface accessor
inline ISteamRemotePlay *SteamRemotePlay(); inline ISteamRemotePlay* SteamRemotePlay();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamRemotePlay *, SteamRemotePlay, STEAMREMOTEPLAY_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamRemotePlay*, SteamRemotePlay, STEAMREMOTEPLAY_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
STEAM_CALLBACK_BEGIN(SteamRemotePlaySessionConnected_t, k_iSteamRemotePlayCallbacks + 1)
STEAM_CALLBACK_MEMBER(0, RemotePlaySessionID_t, m_unSessionID)
STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( SteamRemotePlaySessionConnected_t, k_iSteamRemotePlayCallbacks + 1 ) STEAM_CALLBACK_BEGIN(SteamRemotePlaySessionDisconnected_t, k_iSteamRemotePlayCallbacks + 2)
STEAM_CALLBACK_MEMBER( 0, RemotePlaySessionID_t, m_unSessionID ) STEAM_CALLBACK_MEMBER(0, RemotePlaySessionID_t, m_unSessionID)
STEAM_CALLBACK_END( 0 ) STEAM_CALLBACK_END(0)
STEAM_CALLBACK_BEGIN( SteamRemotePlaySessionDisconnected_t, k_iSteamRemotePlayCallbacks + 2 )
STEAM_CALLBACK_MEMBER( 0, RemotePlaySessionID_t, m_unSessionID )
STEAM_CALLBACK_END( 0 )
#pragma pack( pop )
#pragma pack(pop)
#endif // #define ISTEAMREMOTEPLAY_H #endif // #define ISTEAMREMOTEPLAY_H

View File

@ -22,86 +22,83 @@ const int k_cubUFSTagValueMax = 255;
const int k_ScreenshotThumbWidth = 200; const int k_ScreenshotThumbWidth = 200;
// Handle is valid for the lifetime of your process and no longer // Handle is valid for the lifetime of your process and no longer
typedef uint32 ScreenshotHandle; typedef uint32 ScreenshotHandle;
#define INVALID_SCREENSHOT_HANDLE 0 #define INVALID_SCREENSHOT_HANDLE 0
enum EVRScreenshotType enum EVRScreenshotType {
{ k_EVRScreenshotType_None = 0,
k_EVRScreenshotType_None = 0, k_EVRScreenshotType_Mono = 1,
k_EVRScreenshotType_Mono = 1, k_EVRScreenshotType_Stereo = 2,
k_EVRScreenshotType_Stereo = 2, k_EVRScreenshotType_MonoCubemap = 3,
k_EVRScreenshotType_MonoCubemap = 3, k_EVRScreenshotType_MonoPanorama = 4,
k_EVRScreenshotType_MonoPanorama = 4, k_EVRScreenshotType_StereoPanorama = 5
k_EVRScreenshotType_StereoPanorama = 5
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for adding screenshots to the user's screenshot library // Purpose: Functions for adding screenshots to the user's screenshot library
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamScreenshots class ISteamScreenshots {
{
public: public:
// Writes a screenshot to the user's screenshot library given the raw image data, which must be in RGB format. // Writes a screenshot to the user's screenshot library given the raw image data, which must be in RGB format.
// The return value is a handle that is valid for the duration of the game process and can be used to apply tags. // The return value is a handle that is valid for the duration of the game process and can be used to apply tags.
virtual ScreenshotHandle WriteScreenshot( void *pubRGB, uint32 cubRGB, int nWidth, int nHeight ) = 0; virtual ScreenshotHandle WriteScreenshot(void* pubRGB, uint32 cubRGB, int nWidth, int nHeight) = 0;
// Adds a screenshot to the user's screenshot library from disk. If a thumbnail is provided, it must be 200 pixels wide and the same aspect ratio // Adds a screenshot to the user's screenshot library from disk. If a thumbnail is provided, it must be 200 pixels wide and the same aspect ratio
// as the screenshot, otherwise a thumbnail will be generated if the user uploads the screenshot. The screenshots must be in either JPEG or TGA format. // as the screenshot, otherwise a thumbnail will be generated if the user uploads the screenshot. The screenshots must be in either JPEG or TGA format.
// The return value is a handle that is valid for the duration of the game process and can be used to apply tags. // The return value is a handle that is valid for the duration of the game process and can be used to apply tags.
// JPEG, TGA, and PNG formats are supported. // JPEG, TGA, and PNG formats are supported.
virtual ScreenshotHandle AddScreenshotToLibrary( const char *pchFilename, const char *pchThumbnailFilename, int nWidth, int nHeight ) = 0; virtual ScreenshotHandle AddScreenshotToLibrary(const char* pchFilename, const char* pchThumbnailFilename, int nWidth, int nHeight) = 0;
// Causes the Steam overlay to take a screenshot. If screenshots are being hooked by the game then a ScreenshotRequested_t callback is sent back to the game instead. // Causes the Steam overlay to take a screenshot. If screenshots are being hooked by the game then a ScreenshotRequested_t callback is sent back to the game instead.
virtual void TriggerScreenshot() = 0; virtual void TriggerScreenshot() = 0;
// Toggles whether the overlay handles screenshots when the user presses the screenshot hotkey, or the game handles them. If the game is hooking screenshots, // Toggles whether the overlay handles screenshots when the user presses the screenshot hotkey, or the game handles them. If the game is hooking screenshots,
// then the ScreenshotRequested_t callback will be sent if the user presses the hotkey, and the game is expected to call WriteScreenshot or AddScreenshotToLibrary // then the ScreenshotRequested_t callback will be sent if the user presses the hotkey, and the game is expected to call WriteScreenshot or AddScreenshotToLibrary
// in response. // in response.
virtual void HookScreenshots( bool bHook ) = 0; virtual void HookScreenshots(bool bHook) = 0;
// Sets metadata about a screenshot's location (for example, the name of the map) // Sets metadata about a screenshot's location (for example, the name of the map)
virtual bool SetLocation( ScreenshotHandle hScreenshot, const char *pchLocation ) = 0; virtual bool SetLocation(ScreenshotHandle hScreenshot, const char* pchLocation) = 0;
// Tags a user as being visible in the screenshot
virtual bool TagUser( ScreenshotHandle hScreenshot, CSteamID steamID ) = 0;
// Tags a published file as being visible in the screenshot // Tags a user as being visible in the screenshot
virtual bool TagPublishedFile( ScreenshotHandle hScreenshot, PublishedFileId_t unPublishedFileID ) = 0; virtual bool TagUser(ScreenshotHandle hScreenshot, CSteamID steamID) = 0;
// Returns true if the app has hooked the screenshot // Tags a published file as being visible in the screenshot
virtual bool IsScreenshotsHooked() = 0; virtual bool TagPublishedFile(ScreenshotHandle hScreenshot, PublishedFileId_t unPublishedFileID) = 0;
// Adds a VR screenshot to the user's screenshot library from disk in the supported type. // Returns true if the app has hooked the screenshot
// pchFilename should be the normal 2D image used in the library view virtual bool IsScreenshotsHooked() = 0;
// pchVRFilename should contain the image that matches the correct type
// The return value is a handle that is valid for the duration of the game process and can be used to apply tags. // Adds a VR screenshot to the user's screenshot library from disk in the supported type.
// JPEG, TGA, and PNG formats are supported. // pchFilename should be the normal 2D image used in the library view
virtual ScreenshotHandle AddVRScreenshotToLibrary( EVRScreenshotType eType, const char *pchFilename, const char *pchVRFilename ) = 0; // pchVRFilename should contain the image that matches the correct type
// The return value is a handle that is valid for the duration of the game process and can be used to apply tags.
// JPEG, TGA, and PNG formats are supported.
virtual ScreenshotHandle AddVRScreenshotToLibrary(EVRScreenshotType eType, const char* pchFilename, const char* pchVRFilename) = 0;
}; };
#define STEAMSCREENSHOTS_INTERFACE_VERSION "STEAMSCREENSHOTS_INTERFACE_VERSION003" #define STEAMSCREENSHOTS_INTERFACE_VERSION "STEAMSCREENSHOTS_INTERFACE_VERSION003"
// Global interface accessor // Global interface accessor
inline ISteamScreenshots *SteamScreenshots(); inline ISteamScreenshots* SteamScreenshots();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamScreenshots *, SteamScreenshots, STEAMSCREENSHOTS_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamScreenshots*, SteamScreenshots, STEAMSCREENSHOTS_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Screenshot successfully written or otherwise added to the library // Purpose: Screenshot successfully written or otherwise added to the library
// and can now be tagged // and can now be tagged
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct ScreenshotReady_t struct ScreenshotReady_t {
{ enum { k_iCallback = k_iSteamScreenshotsCallbacks + 1 };
enum { k_iCallback = k_iSteamScreenshotsCallbacks + 1 }; ScreenshotHandle m_hLocal;
ScreenshotHandle m_hLocal; EResult m_eResult;
EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -109,12 +106,10 @@ struct ScreenshotReady_t
// HookScreenshots() has been called, in which case Steam will not take // HookScreenshots() has been called, in which case Steam will not take
// the screenshot itself. // the screenshot itself.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct ScreenshotRequested_t struct ScreenshotRequested_t {
{ enum { k_iCallback = k_iSteamScreenshotsCallbacks + 2 };
enum { k_iCallback = k_iSteamScreenshotsCallbacks + 2 };
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMSCREENSHOTS_H #endif // ISTEAMSCREENSHOTS_H

View File

@ -10,562 +10,525 @@
#pragma once #pragma once
#endif #endif
#include "steam_api_common.h"
#include "isteamremotestorage.h" #include "isteamremotestorage.h"
#include "steam_api_common.h"
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
typedef uint64 UGCQueryHandle_t; typedef uint64 UGCQueryHandle_t;
typedef uint64 UGCUpdateHandle_t; typedef uint64 UGCUpdateHandle_t;
const UGCQueryHandle_t k_UGCQueryHandleInvalid = 0xffffffffffffffffull; const UGCQueryHandle_t k_UGCQueryHandleInvalid = 0xffffffffffffffffull;
const UGCUpdateHandle_t k_UGCUpdateHandleInvalid = 0xffffffffffffffffull; const UGCUpdateHandle_t k_UGCUpdateHandleInvalid = 0xffffffffffffffffull;
// Matching UGC types for queries // Matching UGC types for queries
enum EUGCMatchingUGCType enum EUGCMatchingUGCType {
{ k_EUGCMatchingUGCType_Items = 0, // both mtx items and ready-to-use items
k_EUGCMatchingUGCType_Items = 0, // both mtx items and ready-to-use items k_EUGCMatchingUGCType_Items_Mtx = 1,
k_EUGCMatchingUGCType_Items_Mtx = 1, k_EUGCMatchingUGCType_Items_ReadyToUse = 2,
k_EUGCMatchingUGCType_Items_ReadyToUse = 2, k_EUGCMatchingUGCType_Collections = 3,
k_EUGCMatchingUGCType_Collections = 3, k_EUGCMatchingUGCType_Artwork = 4,
k_EUGCMatchingUGCType_Artwork = 4, k_EUGCMatchingUGCType_Videos = 5,
k_EUGCMatchingUGCType_Videos = 5, k_EUGCMatchingUGCType_Screenshots = 6,
k_EUGCMatchingUGCType_Screenshots = 6, k_EUGCMatchingUGCType_AllGuides = 7, // both web guides and integrated guides
k_EUGCMatchingUGCType_AllGuides = 7, // both web guides and integrated guides k_EUGCMatchingUGCType_WebGuides = 8,
k_EUGCMatchingUGCType_WebGuides = 8, k_EUGCMatchingUGCType_IntegratedGuides = 9,
k_EUGCMatchingUGCType_IntegratedGuides = 9, k_EUGCMatchingUGCType_UsableInGame = 10, // ready-to-use items and integrated guides
k_EUGCMatchingUGCType_UsableInGame = 10, // ready-to-use items and integrated guides k_EUGCMatchingUGCType_ControllerBindings = 11,
k_EUGCMatchingUGCType_ControllerBindings = 11, k_EUGCMatchingUGCType_GameManagedItems = 12, // game managed items (not managed by users)
k_EUGCMatchingUGCType_GameManagedItems = 12, // game managed items (not managed by users) k_EUGCMatchingUGCType_All = ~0, // @note: will only be valid for CreateQueryUserUGCRequest requests
k_EUGCMatchingUGCType_All = ~0, // @note: will only be valid for CreateQueryUserUGCRequest requests
}; };
// Different lists of published UGC for a user. // Different lists of published UGC for a user.
// If the current logged in user is different than the specified user, then some options may not be allowed. // If the current logged in user is different than the specified user, then some options may not be allowed.
enum EUserUGCList enum EUserUGCList {
{ k_EUserUGCList_Published,
k_EUserUGCList_Published, k_EUserUGCList_VotedOn,
k_EUserUGCList_VotedOn, k_EUserUGCList_VotedUp,
k_EUserUGCList_VotedUp, k_EUserUGCList_VotedDown,
k_EUserUGCList_VotedDown, k_EUserUGCList_WillVoteLater,
k_EUserUGCList_WillVoteLater, k_EUserUGCList_Favorited,
k_EUserUGCList_Favorited, k_EUserUGCList_Subscribed,
k_EUserUGCList_Subscribed, k_EUserUGCList_UsedOrPlayed,
k_EUserUGCList_UsedOrPlayed, k_EUserUGCList_Followed,
k_EUserUGCList_Followed,
}; };
// Sort order for user published UGC lists (defaults to creation order descending) // Sort order for user published UGC lists (defaults to creation order descending)
enum EUserUGCListSortOrder enum EUserUGCListSortOrder {
{ k_EUserUGCListSortOrder_CreationOrderDesc,
k_EUserUGCListSortOrder_CreationOrderDesc, k_EUserUGCListSortOrder_CreationOrderAsc,
k_EUserUGCListSortOrder_CreationOrderAsc, k_EUserUGCListSortOrder_TitleAsc,
k_EUserUGCListSortOrder_TitleAsc, k_EUserUGCListSortOrder_LastUpdatedDesc,
k_EUserUGCListSortOrder_LastUpdatedDesc, k_EUserUGCListSortOrder_SubscriptionDateDesc,
k_EUserUGCListSortOrder_SubscriptionDateDesc, k_EUserUGCListSortOrder_VoteScoreDesc,
k_EUserUGCListSortOrder_VoteScoreDesc, k_EUserUGCListSortOrder_ForModeration,
k_EUserUGCListSortOrder_ForModeration,
}; };
// Combination of sorting and filtering for queries across all UGC // Combination of sorting and filtering for queries across all UGC
enum EUGCQuery enum EUGCQuery {
{ k_EUGCQuery_RankedByVote = 0,
k_EUGCQuery_RankedByVote = 0, k_EUGCQuery_RankedByPublicationDate = 1,
k_EUGCQuery_RankedByPublicationDate = 1, k_EUGCQuery_AcceptedForGameRankedByAcceptanceDate = 2,
k_EUGCQuery_AcceptedForGameRankedByAcceptanceDate = 2, k_EUGCQuery_RankedByTrend = 3,
k_EUGCQuery_RankedByTrend = 3, k_EUGCQuery_FavoritedByFriendsRankedByPublicationDate = 4,
k_EUGCQuery_FavoritedByFriendsRankedByPublicationDate = 4, k_EUGCQuery_CreatedByFriendsRankedByPublicationDate = 5,
k_EUGCQuery_CreatedByFriendsRankedByPublicationDate = 5, k_EUGCQuery_RankedByNumTimesReported = 6,
k_EUGCQuery_RankedByNumTimesReported = 6, k_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate = 7,
k_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate = 7, k_EUGCQuery_NotYetRated = 8,
k_EUGCQuery_NotYetRated = 8, k_EUGCQuery_RankedByTotalVotesAsc = 9,
k_EUGCQuery_RankedByTotalVotesAsc = 9, k_EUGCQuery_RankedByVotesUp = 10,
k_EUGCQuery_RankedByVotesUp = 10, k_EUGCQuery_RankedByTextSearch = 11,
k_EUGCQuery_RankedByTextSearch = 11, k_EUGCQuery_RankedByTotalUniqueSubscriptions = 12,
k_EUGCQuery_RankedByTotalUniqueSubscriptions = 12, k_EUGCQuery_RankedByPlaytimeTrend = 13,
k_EUGCQuery_RankedByPlaytimeTrend = 13, k_EUGCQuery_RankedByTotalPlaytime = 14,
k_EUGCQuery_RankedByTotalPlaytime = 14, k_EUGCQuery_RankedByAveragePlaytimeTrend = 15,
k_EUGCQuery_RankedByAveragePlaytimeTrend = 15, k_EUGCQuery_RankedByLifetimeAveragePlaytime = 16,
k_EUGCQuery_RankedByLifetimeAveragePlaytime = 16, k_EUGCQuery_RankedByPlaytimeSessionsTrend = 17,
k_EUGCQuery_RankedByPlaytimeSessionsTrend = 17, k_EUGCQuery_RankedByLifetimePlaytimeSessions = 18,
k_EUGCQuery_RankedByLifetimePlaytimeSessions = 18,
}; };
enum EItemUpdateStatus enum EItemUpdateStatus {
{ k_EItemUpdateStatusInvalid = 0, // The item update handle was invalid, job might be finished, listen too SubmitItemUpdateResult_t
k_EItemUpdateStatusInvalid = 0, // The item update handle was invalid, job might be finished, listen too SubmitItemUpdateResult_t k_EItemUpdateStatusPreparingConfig = 1, // The item update is processing configuration data
k_EItemUpdateStatusPreparingConfig = 1, // The item update is processing configuration data k_EItemUpdateStatusPreparingContent = 2, // The item update is reading and processing content files
k_EItemUpdateStatusPreparingContent = 2, // The item update is reading and processing content files k_EItemUpdateStatusUploadingContent = 3, // The item update is uploading content changes to Steam
k_EItemUpdateStatusUploadingContent = 3, // The item update is uploading content changes to Steam k_EItemUpdateStatusUploadingPreviewFile = 4, // The item update is uploading new preview file image
k_EItemUpdateStatusUploadingPreviewFile = 4, // The item update is uploading new preview file image k_EItemUpdateStatusCommittingChanges = 5 // The item update is committing all changes
k_EItemUpdateStatusCommittingChanges = 5 // The item update is committing all changes
}; };
enum EItemState enum EItemState {
{ k_EItemStateNone = 0, // item not tracked on client
k_EItemStateNone = 0, // item not tracked on client k_EItemStateSubscribed = 1, // current user is subscribed to this item. Not just cached.
k_EItemStateSubscribed = 1, // current user is subscribed to this item. Not just cached. k_EItemStateLegacyItem = 2, // item was created with ISteamRemoteStorage
k_EItemStateLegacyItem = 2, // item was created with ISteamRemoteStorage k_EItemStateInstalled = 4, // item is installed and usable (but maybe out of date)
k_EItemStateInstalled = 4, // item is installed and usable (but maybe out of date) k_EItemStateNeedsUpdate = 8, // items needs an update. Either because it's not installed yet or creator updated content
k_EItemStateNeedsUpdate = 8, // items needs an update. Either because it's not installed yet or creator updated content k_EItemStateDownloading = 16, // item update is currently downloading
k_EItemStateDownloading = 16, // item update is currently downloading k_EItemStateDownloadPending = 32, // DownloadItem() was called for this item, content isn't available until DownloadItemResult_t is fired
k_EItemStateDownloadPending = 32, // DownloadItem() was called for this item, content isn't available until DownloadItemResult_t is fired
}; };
enum EItemStatistic enum EItemStatistic {
{ k_EItemStatistic_NumSubscriptions = 0,
k_EItemStatistic_NumSubscriptions = 0, k_EItemStatistic_NumFavorites = 1,
k_EItemStatistic_NumFavorites = 1, k_EItemStatistic_NumFollowers = 2,
k_EItemStatistic_NumFollowers = 2, k_EItemStatistic_NumUniqueSubscriptions = 3,
k_EItemStatistic_NumUniqueSubscriptions = 3, k_EItemStatistic_NumUniqueFavorites = 4,
k_EItemStatistic_NumUniqueFavorites = 4, k_EItemStatistic_NumUniqueFollowers = 5,
k_EItemStatistic_NumUniqueFollowers = 5, k_EItemStatistic_NumUniqueWebsiteViews = 6,
k_EItemStatistic_NumUniqueWebsiteViews = 6, k_EItemStatistic_ReportScore = 7,
k_EItemStatistic_ReportScore = 7, k_EItemStatistic_NumSecondsPlayed = 8,
k_EItemStatistic_NumSecondsPlayed = 8, k_EItemStatistic_NumPlaytimeSessions = 9,
k_EItemStatistic_NumPlaytimeSessions = 9, k_EItemStatistic_NumComments = 10,
k_EItemStatistic_NumComments = 10, k_EItemStatistic_NumSecondsPlayedDuringTimePeriod = 11,
k_EItemStatistic_NumSecondsPlayedDuringTimePeriod = 11, k_EItemStatistic_NumPlaytimeSessionsDuringTimePeriod = 12,
k_EItemStatistic_NumPlaytimeSessionsDuringTimePeriod = 12,
}; };
enum EItemPreviewType enum EItemPreviewType {
{ k_EItemPreviewType_Image = 0, // standard image file expected (e.g. jpg, png, gif, etc.)
k_EItemPreviewType_Image = 0, // standard image file expected (e.g. jpg, png, gif, etc.) k_EItemPreviewType_YouTubeVideo = 1, // video id is stored
k_EItemPreviewType_YouTubeVideo = 1, // video id is stored k_EItemPreviewType_Sketchfab = 2, // model id is stored
k_EItemPreviewType_Sketchfab = 2, // model id is stored k_EItemPreviewType_EnvironmentMap_HorizontalCross = 3, // standard image file expected - cube map in the layout
k_EItemPreviewType_EnvironmentMap_HorizontalCross = 3, // standard image file expected - cube map in the layout // +---+---+-------+
// +---+---+-------+ // | |Up | |
// | |Up | | // +---+---+---+---+
// +---+---+---+---+ // | L | F | R | B |
// | L | F | R | B | // +---+---+---+---+
// +---+---+---+---+ // | |Dn | |
// | |Dn | | // +---+---+---+---+
// +---+---+---+---+ k_EItemPreviewType_EnvironmentMap_LatLong = 4, // standard image file expected
k_EItemPreviewType_EnvironmentMap_LatLong = 4, // standard image file expected k_EItemPreviewType_ReservedMax = 255, // you can specify your own types above this value
k_EItemPreviewType_ReservedMax = 255, // you can specify your own types above this value
}; };
const uint32 kNumUGCResultsPerPage = 50; const uint32 kNumUGCResultsPerPage = 50;
const uint32 k_cchDeveloperMetadataMax = 5000; const uint32 k_cchDeveloperMetadataMax = 5000;
// Details for a single published file/UGC // Details for a single published file/UGC
struct SteamUGCDetails_t struct SteamUGCDetails_t {
{ PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; EResult m_eResult; // The result of the operation.
EResult m_eResult; // The result of the operation. EWorkshopFileType m_eFileType; // Type of the file
EWorkshopFileType m_eFileType; // Type of the file AppId_t m_nCreatorAppID; // ID of the app that created this file.
AppId_t m_nCreatorAppID; // ID of the app that created this file. AppId_t m_nConsumerAppID; // ID of the app that will consume this file.
AppId_t m_nConsumerAppID; // ID of the app that will consume this file. char m_rgchTitle[k_cchPublishedDocumentTitleMax]; // title of document
char m_rgchTitle[k_cchPublishedDocumentTitleMax]; // title of document char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; // description of document
char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; // description of document uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content.
uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content. uint32 m_rtimeCreated; // time when the published file was created
uint32 m_rtimeCreated; // time when the published file was created uint32 m_rtimeUpdated; // time when the published file was last updated
uint32 m_rtimeUpdated; // time when the published file was last updated uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable)
uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable) ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility
ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility bool m_bBanned; // whether the file was banned
bool m_bBanned; // whether the file was banned bool m_bAcceptedForUse; // developer has specifically flagged this item as accepted in the Workshop
bool m_bAcceptedForUse; // developer has specifically flagged this item as accepted in the Workshop bool m_bTagsTruncated; // whether the list of tags was too long to be returned in the provided buffer
bool m_bTagsTruncated; // whether the list of tags was too long to be returned in the provided buffer char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file
char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file // file/url information
// file/url information UGCHandle_t m_hFile; // The handle of the primary file
UGCHandle_t m_hFile; // The handle of the primary file UGCHandle_t m_hPreviewFile; // The handle of the preview file
UGCHandle_t m_hPreviewFile; // The handle of the preview file char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file
char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file int32 m_nFileSize; // Size of the primary file
int32 m_nFileSize; // Size of the primary file int32 m_nPreviewFileSize; // Size of the preview file
int32 m_nPreviewFileSize; // Size of the preview file char m_rgchURL[k_cchPublishedFileURLMax]; // URL (for a video or a website)
char m_rgchURL[k_cchPublishedFileURLMax]; // URL (for a video or a website) // voting information
// voting information uint32 m_unVotesUp; // number of votes up
uint32 m_unVotesUp; // number of votes up uint32 m_unVotesDown; // number of votes down
uint32 m_unVotesDown; // number of votes down float m_flScore; // calculated score
float m_flScore; // calculated score // collection details
// collection details uint32 m_unNumChildren;
uint32 m_unNumChildren;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Steam UGC support API // Purpose: Steam UGC support API
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamUGC class ISteamUGC {
{
public: public:
// Query UGC associated with a user. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1.
virtual UGCQueryHandle_t CreateQueryUserUGCRequest(AccountID_t unAccountID, EUserUGCList eListType, EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage) = 0;
// Query UGC associated with a user. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1. // Query for all matching UGC. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1.
virtual UGCQueryHandle_t CreateQueryUserUGCRequest( AccountID_t unAccountID, EUserUGCList eListType, EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage ) = 0; STEAM_FLAT_NAME(CreateQueryAllUGCRequestPage)
virtual UGCQueryHandle_t CreateQueryAllUGCRequest(EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage) = 0;
// Query for all matching UGC. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1. // Query for all matching UGC using the new deep paging interface. Creator app id or consumer app id must be valid and be set to the current running app. pchCursor should be set to NULL or "*" to get the first result set.
STEAM_FLAT_NAME( CreateQueryAllUGCRequestPage ) STEAM_FLAT_NAME(CreateQueryAllUGCRequestCursor)
virtual UGCQueryHandle_t CreateQueryAllUGCRequest( EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage ) = 0; virtual UGCQueryHandle_t CreateQueryAllUGCRequest(EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, const char* pchCursor = NULL) = 0;
// Query for all matching UGC using the new deep paging interface. Creator app id or consumer app id must be valid and be set to the current running app. pchCursor should be set to NULL or "*" to get the first result set. // Query for the details of the given published file ids (the RequestUGCDetails call is deprecated and replaced with this)
STEAM_FLAT_NAME( CreateQueryAllUGCRequestCursor ) virtual UGCQueryHandle_t CreateQueryUGCDetailsRequest(PublishedFileId_t* pvecPublishedFileID, uint32 unNumPublishedFileIDs) = 0;
virtual UGCQueryHandle_t CreateQueryAllUGCRequest( EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, const char *pchCursor = NULL ) = 0;
// Query for the details of the given published file ids (the RequestUGCDetails call is deprecated and replaced with this) // Send the query to Steam
virtual UGCQueryHandle_t CreateQueryUGCDetailsRequest( PublishedFileId_t *pvecPublishedFileID, uint32 unNumPublishedFileIDs ) = 0; STEAM_CALL_RESULT(SteamUGCQueryCompleted_t)
virtual SteamAPICall_t SendQueryUGCRequest(UGCQueryHandle_t handle) = 0;
// Send the query to Steam // Retrieve an individual result after receiving the callback for querying UGC
STEAM_CALL_RESULT( SteamUGCQueryCompleted_t ) virtual bool GetQueryUGCResult(UGCQueryHandle_t handle, uint32 index, SteamUGCDetails_t* pDetails) = 0;
virtual SteamAPICall_t SendQueryUGCRequest( UGCQueryHandle_t handle ) = 0; virtual uint32 GetQueryUGCNumTags(UGCQueryHandle_t handle, uint32 index) = 0;
virtual bool GetQueryUGCTag(UGCQueryHandle_t handle, uint32 index, uint32 indexTag, STEAM_OUT_STRING_COUNT(cchValueSize) char* pchValue, uint32 cchValueSize) = 0;
virtual bool GetQueryUGCTagDisplayName(UGCQueryHandle_t handle, uint32 index, uint32 indexTag, STEAM_OUT_STRING_COUNT(cchValueSize) char* pchValue, uint32 cchValueSize) = 0;
virtual bool GetQueryUGCPreviewURL(UGCQueryHandle_t handle, uint32 index, STEAM_OUT_STRING_COUNT(cchURLSize) char* pchURL, uint32 cchURLSize) = 0;
virtual bool GetQueryUGCMetadata(UGCQueryHandle_t handle, uint32 index, STEAM_OUT_STRING_COUNT(cchMetadatasize) char* pchMetadata, uint32 cchMetadatasize) = 0;
virtual bool GetQueryUGCChildren(UGCQueryHandle_t handle, uint32 index, PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries) = 0;
virtual bool GetQueryUGCStatistic(UGCQueryHandle_t handle, uint32 index, EItemStatistic eStatType, uint64* pStatValue) = 0;
virtual uint32 GetQueryUGCNumAdditionalPreviews(UGCQueryHandle_t handle, uint32 index) = 0;
virtual bool GetQueryUGCAdditionalPreview(UGCQueryHandle_t handle, uint32 index, uint32 previewIndex, STEAM_OUT_STRING_COUNT(cchURLSize) char* pchURLOrVideoID, uint32 cchURLSize, STEAM_OUT_STRING_COUNT(cchURLSize) char* pchOriginalFileName, uint32 cchOriginalFileNameSize, EItemPreviewType* pPreviewType) = 0;
virtual uint32 GetQueryUGCNumKeyValueTags(UGCQueryHandle_t handle, uint32 index) = 0;
virtual bool GetQueryUGCKeyValueTag(UGCQueryHandle_t handle, uint32 index, uint32 keyValueTagIndex, STEAM_OUT_STRING_COUNT(cchKeySize) char* pchKey, uint32 cchKeySize, STEAM_OUT_STRING_COUNT(cchValueSize) char* pchValue, uint32 cchValueSize) = 0;
// Retrieve an individual result after receiving the callback for querying UGC // Return the first value matching the pchKey. Note that a key may map to multiple values. Returns false if there was an error or no matching value was found.
virtual bool GetQueryUGCResult( UGCQueryHandle_t handle, uint32 index, SteamUGCDetails_t *pDetails ) = 0; STEAM_FLAT_NAME(GetQueryFirstUGCKeyValueTag)
virtual uint32 GetQueryUGCNumTags( UGCQueryHandle_t handle, uint32 index ) = 0; virtual bool GetQueryUGCKeyValueTag(UGCQueryHandle_t handle, uint32 index, const char* pchKey, STEAM_OUT_STRING_COUNT(cchValueSize) char* pchValue, uint32 cchValueSize) = 0;
virtual bool GetQueryUGCTag( UGCQueryHandle_t handle, uint32 index, uint32 indexTag, STEAM_OUT_STRING_COUNT( cchValueSize ) char* pchValue, uint32 cchValueSize ) = 0;
virtual bool GetQueryUGCTagDisplayName( UGCQueryHandle_t handle, uint32 index, uint32 indexTag, STEAM_OUT_STRING_COUNT( cchValueSize ) char* pchValue, uint32 cchValueSize ) = 0;
virtual bool GetQueryUGCPreviewURL( UGCQueryHandle_t handle, uint32 index, STEAM_OUT_STRING_COUNT(cchURLSize) char *pchURL, uint32 cchURLSize ) = 0;
virtual bool GetQueryUGCMetadata( UGCQueryHandle_t handle, uint32 index, STEAM_OUT_STRING_COUNT(cchMetadatasize) char *pchMetadata, uint32 cchMetadatasize ) = 0;
virtual bool GetQueryUGCChildren( UGCQueryHandle_t handle, uint32 index, PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries ) = 0;
virtual bool GetQueryUGCStatistic( UGCQueryHandle_t handle, uint32 index, EItemStatistic eStatType, uint64 *pStatValue ) = 0;
virtual uint32 GetQueryUGCNumAdditionalPreviews( UGCQueryHandle_t handle, uint32 index ) = 0;
virtual bool GetQueryUGCAdditionalPreview( UGCQueryHandle_t handle, uint32 index, uint32 previewIndex, STEAM_OUT_STRING_COUNT(cchURLSize) char *pchURLOrVideoID, uint32 cchURLSize, STEAM_OUT_STRING_COUNT(cchURLSize) char *pchOriginalFileName, uint32 cchOriginalFileNameSize, EItemPreviewType *pPreviewType ) = 0;
virtual uint32 GetQueryUGCNumKeyValueTags( UGCQueryHandle_t handle, uint32 index ) = 0;
virtual bool GetQueryUGCKeyValueTag( UGCQueryHandle_t handle, uint32 index, uint32 keyValueTagIndex, STEAM_OUT_STRING_COUNT(cchKeySize) char *pchKey, uint32 cchKeySize, STEAM_OUT_STRING_COUNT(cchValueSize) char *pchValue, uint32 cchValueSize ) = 0;
// Return the first value matching the pchKey. Note that a key may map to multiple values. Returns false if there was an error or no matching value was found. // Release the request to free up memory, after retrieving results
STEAM_FLAT_NAME( GetQueryFirstUGCKeyValueTag ) virtual bool ReleaseQueryUGCRequest(UGCQueryHandle_t handle) = 0;
virtual bool GetQueryUGCKeyValueTag( UGCQueryHandle_t handle, uint32 index, const char *pchKey, STEAM_OUT_STRING_COUNT(cchValueSize) char *pchValue, uint32 cchValueSize ) = 0;
// Release the request to free up memory, after retrieving results // Options to set for querying UGC
virtual bool ReleaseQueryUGCRequest( UGCQueryHandle_t handle ) = 0; virtual bool AddRequiredTag(UGCQueryHandle_t handle, const char* pTagName) = 0;
virtual bool AddRequiredTagGroup(UGCQueryHandle_t handle, const SteamParamStringArray_t* pTagGroups) = 0; // match any of the tags in this group
virtual bool AddExcludedTag(UGCQueryHandle_t handle, const char* pTagName) = 0;
virtual bool SetReturnOnlyIDs(UGCQueryHandle_t handle, bool bReturnOnlyIDs) = 0;
virtual bool SetReturnKeyValueTags(UGCQueryHandle_t handle, bool bReturnKeyValueTags) = 0;
virtual bool SetReturnLongDescription(UGCQueryHandle_t handle, bool bReturnLongDescription) = 0;
virtual bool SetReturnMetadata(UGCQueryHandle_t handle, bool bReturnMetadata) = 0;
virtual bool SetReturnChildren(UGCQueryHandle_t handle, bool bReturnChildren) = 0;
virtual bool SetReturnAdditionalPreviews(UGCQueryHandle_t handle, bool bReturnAdditionalPreviews) = 0;
virtual bool SetReturnTotalOnly(UGCQueryHandle_t handle, bool bReturnTotalOnly) = 0;
virtual bool SetReturnPlaytimeStats(UGCQueryHandle_t handle, uint32 unDays) = 0;
virtual bool SetLanguage(UGCQueryHandle_t handle, const char* pchLanguage) = 0;
virtual bool SetAllowCachedResponse(UGCQueryHandle_t handle, uint32 unMaxAgeSeconds) = 0;
// Options to set for querying UGC // Options only for querying user UGC
virtual bool AddRequiredTag( UGCQueryHandle_t handle, const char *pTagName ) = 0; virtual bool SetCloudFileNameFilter(UGCQueryHandle_t handle, const char* pMatchCloudFileName) = 0;
virtual bool AddRequiredTagGroup( UGCQueryHandle_t handle, const SteamParamStringArray_t *pTagGroups ) = 0; // match any of the tags in this group
virtual bool AddExcludedTag( UGCQueryHandle_t handle, const char *pTagName ) = 0;
virtual bool SetReturnOnlyIDs( UGCQueryHandle_t handle, bool bReturnOnlyIDs ) = 0;
virtual bool SetReturnKeyValueTags( UGCQueryHandle_t handle, bool bReturnKeyValueTags ) = 0;
virtual bool SetReturnLongDescription( UGCQueryHandle_t handle, bool bReturnLongDescription ) = 0;
virtual bool SetReturnMetadata( UGCQueryHandle_t handle, bool bReturnMetadata ) = 0;
virtual bool SetReturnChildren( UGCQueryHandle_t handle, bool bReturnChildren ) = 0;
virtual bool SetReturnAdditionalPreviews( UGCQueryHandle_t handle, bool bReturnAdditionalPreviews ) = 0;
virtual bool SetReturnTotalOnly( UGCQueryHandle_t handle, bool bReturnTotalOnly ) = 0;
virtual bool SetReturnPlaytimeStats( UGCQueryHandle_t handle, uint32 unDays ) = 0;
virtual bool SetLanguage( UGCQueryHandle_t handle, const char *pchLanguage ) = 0;
virtual bool SetAllowCachedResponse( UGCQueryHandle_t handle, uint32 unMaxAgeSeconds ) = 0;
// Options only for querying user UGC // Options only for querying all UGC
virtual bool SetCloudFileNameFilter( UGCQueryHandle_t handle, const char *pMatchCloudFileName ) = 0; virtual bool SetMatchAnyTag(UGCQueryHandle_t handle, bool bMatchAnyTag) = 0;
virtual bool SetSearchText(UGCQueryHandle_t handle, const char* pSearchText) = 0;
virtual bool SetRankedByTrendDays(UGCQueryHandle_t handle, uint32 unDays) = 0;
virtual bool AddRequiredKeyValueTag(UGCQueryHandle_t handle, const char* pKey, const char* pValue) = 0;
// Options only for querying all UGC // DEPRECATED - Use CreateQueryUGCDetailsRequest call above instead!
virtual bool SetMatchAnyTag( UGCQueryHandle_t handle, bool bMatchAnyTag ) = 0; STEAM_CALL_RESULT(SteamUGCRequestUGCDetailsResult_t)
virtual bool SetSearchText( UGCQueryHandle_t handle, const char *pSearchText ) = 0; virtual SteamAPICall_t RequestUGCDetails(PublishedFileId_t nPublishedFileID, uint32 unMaxAgeSeconds) = 0;
virtual bool SetRankedByTrendDays( UGCQueryHandle_t handle, uint32 unDays ) = 0;
virtual bool AddRequiredKeyValueTag( UGCQueryHandle_t handle, const char *pKey, const char *pValue ) = 0;
// DEPRECATED - Use CreateQueryUGCDetailsRequest call above instead! // Steam Workshop Creator API
STEAM_CALL_RESULT( SteamUGCRequestUGCDetailsResult_t ) STEAM_CALL_RESULT(CreateItemResult_t)
virtual SteamAPICall_t RequestUGCDetails( PublishedFileId_t nPublishedFileID, uint32 unMaxAgeSeconds ) = 0; virtual SteamAPICall_t CreateItem(AppId_t nConsumerAppId, EWorkshopFileType eFileType) = 0; // create new item for this app with no content attached yet
// Steam Workshop Creator API virtual UGCUpdateHandle_t StartItemUpdate(AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID) = 0; // start an UGC item update. Set changed properties before commiting update with CommitItemUpdate()
STEAM_CALL_RESULT( CreateItemResult_t )
virtual SteamAPICall_t CreateItem( AppId_t nConsumerAppId, EWorkshopFileType eFileType ) = 0; // create new item for this app with no content attached yet
virtual UGCUpdateHandle_t StartItemUpdate( AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID ) = 0; // start an UGC item update. Set changed properties before commiting update with CommitItemUpdate() virtual bool SetItemTitle(UGCUpdateHandle_t handle, const char* pchTitle) = 0; // change the title of an UGC item
virtual bool SetItemDescription(UGCUpdateHandle_t handle, const char* pchDescription) = 0; // change the description of an UGC item
virtual bool SetItemUpdateLanguage(UGCUpdateHandle_t handle, const char* pchLanguage) = 0; // specify the language of the title or description that will be set
virtual bool SetItemMetadata(UGCUpdateHandle_t handle, const char* pchMetaData) = 0; // change the metadata of an UGC item (max = k_cchDeveloperMetadataMax)
virtual bool SetItemVisibility(UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility) = 0; // change the visibility of an UGC item
virtual bool SetItemTags(UGCUpdateHandle_t updateHandle, const SteamParamStringArray_t* pTags) = 0; // change the tags of an UGC item
virtual bool SetItemContent(UGCUpdateHandle_t handle, const char* pszContentFolder) = 0; // update item content from this local folder
virtual bool SetItemPreview(UGCUpdateHandle_t handle, const char* pszPreviewFile) = 0; // change preview image file for this item. pszPreviewFile points to local image file, which must be under 1MB in size
virtual bool SetAllowLegacyUpload(UGCUpdateHandle_t handle, bool bAllowLegacyUpload) = 0; // use legacy upload for a single small file. The parameter to SetItemContent() should either be a directory with one file or the full path to the file. The file must also be less than 10MB in size.
virtual bool RemoveAllItemKeyValueTags(UGCUpdateHandle_t handle) = 0; // remove all existing key-value tags (you can add new ones via the AddItemKeyValueTag function)
virtual bool RemoveItemKeyValueTags(UGCUpdateHandle_t handle, const char* pchKey) = 0; // remove any existing key-value tags with the specified key
virtual bool AddItemKeyValueTag(UGCUpdateHandle_t handle, const char* pchKey, const char* pchValue) = 0; // add new key-value tags for the item. Note that there can be multiple values for a tag.
virtual bool AddItemPreviewFile(UGCUpdateHandle_t handle, const char* pszPreviewFile, EItemPreviewType type) = 0; // add preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
virtual bool AddItemPreviewVideo(UGCUpdateHandle_t handle, const char* pszVideoID) = 0; // add preview video for this item
virtual bool UpdateItemPreviewFile(UGCUpdateHandle_t handle, uint32 index, const char* pszPreviewFile) = 0; // updates an existing preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
virtual bool UpdateItemPreviewVideo(UGCUpdateHandle_t handle, uint32 index, const char* pszVideoID) = 0; // updates an existing preview video for this item
virtual bool RemoveItemPreview(UGCUpdateHandle_t handle, uint32 index) = 0; // remove a preview by index starting at 0 (previews are sorted)
virtual bool SetItemTitle( UGCUpdateHandle_t handle, const char *pchTitle ) = 0; // change the title of an UGC item STEAM_CALL_RESULT(SubmitItemUpdateResult_t)
virtual bool SetItemDescription( UGCUpdateHandle_t handle, const char *pchDescription ) = 0; // change the description of an UGC item virtual SteamAPICall_t SubmitItemUpdate(UGCUpdateHandle_t handle, const char* pchChangeNote) = 0; // commit update process started with StartItemUpdate()
virtual bool SetItemUpdateLanguage( UGCUpdateHandle_t handle, const char *pchLanguage ) = 0; // specify the language of the title or description that will be set virtual EItemUpdateStatus GetItemUpdateProgress(UGCUpdateHandle_t handle, uint64* punBytesProcessed, uint64* punBytesTotal) = 0;
virtual bool SetItemMetadata( UGCUpdateHandle_t handle, const char *pchMetaData ) = 0; // change the metadata of an UGC item (max = k_cchDeveloperMetadataMax)
virtual bool SetItemVisibility( UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility ) = 0; // change the visibility of an UGC item
virtual bool SetItemTags( UGCUpdateHandle_t updateHandle, const SteamParamStringArray_t *pTags ) = 0; // change the tags of an UGC item
virtual bool SetItemContent( UGCUpdateHandle_t handle, const char *pszContentFolder ) = 0; // update item content from this local folder
virtual bool SetItemPreview( UGCUpdateHandle_t handle, const char *pszPreviewFile ) = 0; // change preview image file for this item. pszPreviewFile points to local image file, which must be under 1MB in size
virtual bool SetAllowLegacyUpload( UGCUpdateHandle_t handle, bool bAllowLegacyUpload ) = 0; // use legacy upload for a single small file. The parameter to SetItemContent() should either be a directory with one file or the full path to the file. The file must also be less than 10MB in size.
virtual bool RemoveAllItemKeyValueTags( UGCUpdateHandle_t handle ) = 0; // remove all existing key-value tags (you can add new ones via the AddItemKeyValueTag function)
virtual bool RemoveItemKeyValueTags( UGCUpdateHandle_t handle, const char *pchKey ) = 0; // remove any existing key-value tags with the specified key
virtual bool AddItemKeyValueTag( UGCUpdateHandle_t handle, const char *pchKey, const char *pchValue ) = 0; // add new key-value tags for the item. Note that there can be multiple values for a tag.
virtual bool AddItemPreviewFile( UGCUpdateHandle_t handle, const char *pszPreviewFile, EItemPreviewType type ) = 0; // add preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
virtual bool AddItemPreviewVideo( UGCUpdateHandle_t handle, const char *pszVideoID ) = 0; // add preview video for this item
virtual bool UpdateItemPreviewFile( UGCUpdateHandle_t handle, uint32 index, const char *pszPreviewFile ) = 0; // updates an existing preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size
virtual bool UpdateItemPreviewVideo( UGCUpdateHandle_t handle, uint32 index, const char *pszVideoID ) = 0; // updates an existing preview video for this item
virtual bool RemoveItemPreview( UGCUpdateHandle_t handle, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
STEAM_CALL_RESULT( SubmitItemUpdateResult_t ) // Steam Workshop Consumer API
virtual SteamAPICall_t SubmitItemUpdate( UGCUpdateHandle_t handle, const char *pchChangeNote ) = 0; // commit update process started with StartItemUpdate() STEAM_CALL_RESULT(SetUserItemVoteResult_t)
virtual EItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, uint64 *punBytesProcessed, uint64* punBytesTotal ) = 0; virtual SteamAPICall_t SetUserItemVote(PublishedFileId_t nPublishedFileID, bool bVoteUp) = 0;
STEAM_CALL_RESULT(GetUserItemVoteResult_t)
virtual SteamAPICall_t GetUserItemVote(PublishedFileId_t nPublishedFileID) = 0;
STEAM_CALL_RESULT(UserFavoriteItemsListChanged_t)
virtual SteamAPICall_t AddItemToFavorites(AppId_t nAppId, PublishedFileId_t nPublishedFileID) = 0;
STEAM_CALL_RESULT(UserFavoriteItemsListChanged_t)
virtual SteamAPICall_t RemoveItemFromFavorites(AppId_t nAppId, PublishedFileId_t nPublishedFileID) = 0;
STEAM_CALL_RESULT(RemoteStorageSubscribePublishedFileResult_t)
virtual SteamAPICall_t SubscribeItem(PublishedFileId_t nPublishedFileID) = 0; // subscribe to this item, will be installed ASAP
STEAM_CALL_RESULT(RemoteStorageUnsubscribePublishedFileResult_t)
virtual SteamAPICall_t UnsubscribeItem(PublishedFileId_t nPublishedFileID) = 0; // unsubscribe from this item, will be uninstalled after game quits
virtual uint32 GetNumSubscribedItems() = 0; // number of subscribed items
virtual uint32 GetSubscribedItems(PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries) = 0; // all subscribed item PublishFileIDs
// Steam Workshop Consumer API // get EItemState flags about item on this client
STEAM_CALL_RESULT( SetUserItemVoteResult_t ) virtual uint32 GetItemState(PublishedFileId_t nPublishedFileID) = 0;
virtual SteamAPICall_t SetUserItemVote( PublishedFileId_t nPublishedFileID, bool bVoteUp ) = 0;
STEAM_CALL_RESULT( GetUserItemVoteResult_t )
virtual SteamAPICall_t GetUserItemVote( PublishedFileId_t nPublishedFileID ) = 0;
STEAM_CALL_RESULT( UserFavoriteItemsListChanged_t )
virtual SteamAPICall_t AddItemToFavorites( AppId_t nAppId, PublishedFileId_t nPublishedFileID ) = 0;
STEAM_CALL_RESULT( UserFavoriteItemsListChanged_t )
virtual SteamAPICall_t RemoveItemFromFavorites( AppId_t nAppId, PublishedFileId_t nPublishedFileID ) = 0;
STEAM_CALL_RESULT( RemoteStorageSubscribePublishedFileResult_t )
virtual SteamAPICall_t SubscribeItem( PublishedFileId_t nPublishedFileID ) = 0; // subscribe to this item, will be installed ASAP
STEAM_CALL_RESULT( RemoteStorageUnsubscribePublishedFileResult_t )
virtual SteamAPICall_t UnsubscribeItem( PublishedFileId_t nPublishedFileID ) = 0; // unsubscribe from this item, will be uninstalled after game quits
virtual uint32 GetNumSubscribedItems() = 0; // number of subscribed items
virtual uint32 GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries ) = 0; // all subscribed item PublishFileIDs
// get EItemState flags about item on this client // get info about currently installed content on disc for items that have k_EItemStateInstalled set
virtual uint32 GetItemState( PublishedFileId_t nPublishedFileID ) = 0; // if k_EItemStateLegacyItem is set, pchFolder contains the path to the legacy file itself (not a folder)
virtual bool GetItemInstallInfo(PublishedFileId_t nPublishedFileID, uint64* punSizeOnDisk, STEAM_OUT_STRING_COUNT(cchFolderSize) char* pchFolder, uint32 cchFolderSize, uint32* punTimeStamp) = 0;
// get info about currently installed content on disc for items that have k_EItemStateInstalled set // get info about pending update for items that have k_EItemStateNeedsUpdate set. punBytesTotal will be valid after download started once
// if k_EItemStateLegacyItem is set, pchFolder contains the path to the legacy file itself (not a folder) virtual bool GetItemDownloadInfo(PublishedFileId_t nPublishedFileID, uint64* punBytesDownloaded, uint64* punBytesTotal) = 0;
virtual bool GetItemInstallInfo( PublishedFileId_t nPublishedFileID, uint64 *punSizeOnDisk, STEAM_OUT_STRING_COUNT( cchFolderSize ) char *pchFolder, uint32 cchFolderSize, uint32 *punTimeStamp ) = 0;
// get info about pending update for items that have k_EItemStateNeedsUpdate set. punBytesTotal will be valid after download started once // download new or update already installed item. If function returns true, wait for DownloadItemResult_t. If the item is already installed,
virtual bool GetItemDownloadInfo( PublishedFileId_t nPublishedFileID, uint64 *punBytesDownloaded, uint64 *punBytesTotal ) = 0; // then files on disk should not be used until callback received. If item is not subscribed to, it will be cached for some time.
// If bHighPriority is set, any other item download will be suspended and this item downloaded ASAP.
// download new or update already installed item. If function returns true, wait for DownloadItemResult_t. If the item is already installed, virtual bool DownloadItem(PublishedFileId_t nPublishedFileID, bool bHighPriority) = 0;
// then files on disk should not be used until callback received. If item is not subscribed to, it will be cached for some time.
// If bHighPriority is set, any other item download will be suspended and this item downloaded ASAP.
virtual bool DownloadItem( PublishedFileId_t nPublishedFileID, bool bHighPriority ) = 0;
// game servers can set a specific workshop folder before issuing any UGC commands. // game servers can set a specific workshop folder before issuing any UGC commands.
// This is helpful if you want to support multiple game servers running out of the same install folder // This is helpful if you want to support multiple game servers running out of the same install folder
virtual bool BInitWorkshopForGameServer( DepotId_t unWorkshopDepotID, const char *pszFolder ) = 0; virtual bool BInitWorkshopForGameServer(DepotId_t unWorkshopDepotID, const char* pszFolder) = 0;
// SuspendDownloads( true ) will suspend all workshop downloads until SuspendDownloads( false ) is called or the game ends // SuspendDownloads( true ) will suspend all workshop downloads until SuspendDownloads( false ) is called or the game ends
virtual void SuspendDownloads( bool bSuspend ) = 0; virtual void SuspendDownloads(bool bSuspend) = 0;
// usage tracking // usage tracking
STEAM_CALL_RESULT( StartPlaytimeTrackingResult_t ) STEAM_CALL_RESULT(StartPlaytimeTrackingResult_t)
virtual SteamAPICall_t StartPlaytimeTracking( PublishedFileId_t *pvecPublishedFileID, uint32 unNumPublishedFileIDs ) = 0; virtual SteamAPICall_t StartPlaytimeTracking(PublishedFileId_t* pvecPublishedFileID, uint32 unNumPublishedFileIDs) = 0;
STEAM_CALL_RESULT( StopPlaytimeTrackingResult_t ) STEAM_CALL_RESULT(StopPlaytimeTrackingResult_t)
virtual SteamAPICall_t StopPlaytimeTracking( PublishedFileId_t *pvecPublishedFileID, uint32 unNumPublishedFileIDs ) = 0; virtual SteamAPICall_t StopPlaytimeTracking(PublishedFileId_t* pvecPublishedFileID, uint32 unNumPublishedFileIDs) = 0;
STEAM_CALL_RESULT( StopPlaytimeTrackingResult_t ) STEAM_CALL_RESULT(StopPlaytimeTrackingResult_t)
virtual SteamAPICall_t StopPlaytimeTrackingForAllItems() = 0; virtual SteamAPICall_t StopPlaytimeTrackingForAllItems() = 0;
// parent-child relationship or dependency management // parent-child relationship or dependency management
STEAM_CALL_RESULT( AddUGCDependencyResult_t ) STEAM_CALL_RESULT(AddUGCDependencyResult_t)
virtual SteamAPICall_t AddDependency( PublishedFileId_t nParentPublishedFileID, PublishedFileId_t nChildPublishedFileID ) = 0; virtual SteamAPICall_t AddDependency(PublishedFileId_t nParentPublishedFileID, PublishedFileId_t nChildPublishedFileID) = 0;
STEAM_CALL_RESULT( RemoveUGCDependencyResult_t ) STEAM_CALL_RESULT(RemoveUGCDependencyResult_t)
virtual SteamAPICall_t RemoveDependency( PublishedFileId_t nParentPublishedFileID, PublishedFileId_t nChildPublishedFileID ) = 0; virtual SteamAPICall_t RemoveDependency(PublishedFileId_t nParentPublishedFileID, PublishedFileId_t nChildPublishedFileID) = 0;
// add/remove app dependence/requirements (usually DLC) // add/remove app dependence/requirements (usually DLC)
STEAM_CALL_RESULT( AddAppDependencyResult_t ) STEAM_CALL_RESULT(AddAppDependencyResult_t)
virtual SteamAPICall_t AddAppDependency( PublishedFileId_t nPublishedFileID, AppId_t nAppID ) = 0; virtual SteamAPICall_t AddAppDependency(PublishedFileId_t nPublishedFileID, AppId_t nAppID) = 0;
STEAM_CALL_RESULT( RemoveAppDependencyResult_t ) STEAM_CALL_RESULT(RemoveAppDependencyResult_t)
virtual SteamAPICall_t RemoveAppDependency( PublishedFileId_t nPublishedFileID, AppId_t nAppID ) = 0; virtual SteamAPICall_t RemoveAppDependency(PublishedFileId_t nPublishedFileID, AppId_t nAppID) = 0;
// request app dependencies. note that whatever callback you register for GetAppDependenciesResult_t may be called multiple times // request app dependencies. note that whatever callback you register for GetAppDependenciesResult_t may be called multiple times
// until all app dependencies have been returned // until all app dependencies have been returned
STEAM_CALL_RESULT( GetAppDependenciesResult_t ) STEAM_CALL_RESULT(GetAppDependenciesResult_t)
virtual SteamAPICall_t GetAppDependencies( PublishedFileId_t nPublishedFileID ) = 0; virtual SteamAPICall_t GetAppDependencies(PublishedFileId_t nPublishedFileID) = 0;
// delete the item without prompting the user // delete the item without prompting the user
STEAM_CALL_RESULT( DeleteItemResult_t ) STEAM_CALL_RESULT(DeleteItemResult_t)
virtual SteamAPICall_t DeleteItem( PublishedFileId_t nPublishedFileID ) = 0; virtual SteamAPICall_t DeleteItem(PublishedFileId_t nPublishedFileID) = 0;
}; };
#define STEAMUGC_INTERFACE_VERSION "STEAMUGC_INTERFACE_VERSION015" #define STEAMUGC_INTERFACE_VERSION "STEAMUGC_INTERFACE_VERSION015"
// Global interface accessor // Global interface accessor
inline ISteamUGC *SteamUGC(); inline ISteamUGC* SteamUGC();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamUGC *, SteamUGC, STEAMUGC_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamUGC*, SteamUGC, STEAMUGC_INTERFACE_VERSION);
// Global accessor for the gameserver client // Global accessor for the gameserver client
inline ISteamUGC *SteamGameServerUGC(); inline ISteamUGC* SteamGameServerUGC();
STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( ISteamUGC *, SteamGameServerUGC, STEAMUGC_INTERFACE_VERSION ); STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(ISteamUGC*, SteamGameServerUGC, STEAMUGC_INTERFACE_VERSION);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback for querying UGC // Purpose: Callback for querying UGC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamUGCQueryCompleted_t struct SteamUGCQueryCompleted_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 1 };
enum { k_iCallback = k_iClientUGCCallbacks + 1 }; UGCQueryHandle_t m_handle;
UGCQueryHandle_t m_handle; EResult m_eResult;
EResult m_eResult; uint32 m_unNumResultsReturned;
uint32 m_unNumResultsReturned; uint32 m_unTotalMatchingResults;
uint32 m_unTotalMatchingResults; bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache
bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache char m_rgchNextCursor[k_cchPublishedFileURLMax]; // If a paging cursor was used, then this will be the next cursor to get the next result set.
char m_rgchNextCursor[k_cchPublishedFileURLMax]; // If a paging cursor was used, then this will be the next cursor to get the next result set.
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback for requesting details on one piece of UGC // Purpose: Callback for requesting details on one piece of UGC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamUGCRequestUGCDetailsResult_t struct SteamUGCRequestUGCDetailsResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 2 };
enum { k_iCallback = k_iClientUGCCallbacks + 2 }; SteamUGCDetails_t m_details;
SteamUGCDetails_t m_details; bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache
bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result for ISteamUGC::CreateItem() // Purpose: result for ISteamUGC::CreateItem()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct CreateItemResult_t struct CreateItemResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 3 };
enum { k_iCallback = k_iClientUGCCallbacks + 3 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId; // new item got this UGC PublishFileID
PublishedFileId_t m_nPublishedFileId; // new item got this UGC PublishFileID bool m_bUserNeedsToAcceptWorkshopLegalAgreement;
bool m_bUserNeedsToAcceptWorkshopLegalAgreement;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result for ISteamUGC::SubmitItemUpdate() // Purpose: result for ISteamUGC::SubmitItemUpdate()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SubmitItemUpdateResult_t struct SubmitItemUpdateResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 4 };
enum { k_iCallback = k_iClientUGCCallbacks + 4 }; EResult m_eResult;
EResult m_eResult; bool m_bUserNeedsToAcceptWorkshopLegalAgreement;
bool m_bUserNeedsToAcceptWorkshopLegalAgreement; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: a Workshop item has been installed or updated // Purpose: a Workshop item has been installed or updated
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct ItemInstalled_t struct ItemInstalled_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 5 };
enum { k_iCallback = k_iClientUGCCallbacks + 5 }; AppId_t m_unAppID;
AppId_t m_unAppID; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result of DownloadItem(), existing item files can be accessed again // Purpose: result of DownloadItem(), existing item files can be accessed again
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct DownloadItemResult_t struct DownloadItemResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 6 };
enum { k_iCallback = k_iClientUGCCallbacks + 6 }; AppId_t m_unAppID;
AppId_t m_unAppID; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; EResult m_eResult;
EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result of AddItemToFavorites() or RemoveItemFromFavorites() // Purpose: result of AddItemToFavorites() or RemoveItemFromFavorites()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct UserFavoriteItemsListChanged_t struct UserFavoriteItemsListChanged_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 7 };
enum { k_iCallback = k_iClientUGCCallbacks + 7 }; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; EResult m_eResult;
EResult m_eResult; bool m_bWasAddRequest;
bool m_bWasAddRequest;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to SetUserItemVote() // Purpose: The result of a call to SetUserItemVote()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SetUserItemVoteResult_t struct SetUserItemVoteResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 8 };
enum { k_iCallback = k_iClientUGCCallbacks + 8 }; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; EResult m_eResult;
EResult m_eResult; bool m_bVoteUp;
bool m_bVoteUp;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to GetUserItemVote() // Purpose: The result of a call to GetUserItemVote()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GetUserItemVoteResult_t struct GetUserItemVoteResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 9 };
enum { k_iCallback = k_iClientUGCCallbacks + 9 }; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; EResult m_eResult;
EResult m_eResult; bool m_bVotedUp;
bool m_bVotedUp; bool m_bVotedDown;
bool m_bVotedDown; bool m_bVoteSkipped;
bool m_bVoteSkipped;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to StartPlaytimeTracking() // Purpose: The result of a call to StartPlaytimeTracking()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct StartPlaytimeTrackingResult_t struct StartPlaytimeTrackingResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 10 };
enum { k_iCallback = k_iClientUGCCallbacks + 10 }; EResult m_eResult;
EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to StopPlaytimeTracking() // Purpose: The result of a call to StopPlaytimeTracking()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct StopPlaytimeTrackingResult_t struct StopPlaytimeTrackingResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 11 };
enum { k_iCallback = k_iClientUGCCallbacks + 11 }; EResult m_eResult;
EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to AddDependency // Purpose: The result of a call to AddDependency
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct AddUGCDependencyResult_t struct AddUGCDependencyResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 12 };
enum { k_iCallback = k_iClientUGCCallbacks + 12 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; PublishedFileId_t m_nChildPublishedFileId;
PublishedFileId_t m_nChildPublishedFileId;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to RemoveDependency // Purpose: The result of a call to RemoveDependency
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct RemoveUGCDependencyResult_t struct RemoveUGCDependencyResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 13 };
enum { k_iCallback = k_iClientUGCCallbacks + 13 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; PublishedFileId_t m_nChildPublishedFileId;
PublishedFileId_t m_nChildPublishedFileId;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to AddAppDependency // Purpose: The result of a call to AddAppDependency
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct AddAppDependencyResult_t struct AddAppDependencyResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 14 };
enum { k_iCallback = k_iClientUGCCallbacks + 14 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; AppId_t m_nAppID;
AppId_t m_nAppID;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to RemoveAppDependency // Purpose: The result of a call to RemoveAppDependency
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct RemoveAppDependencyResult_t struct RemoveAppDependencyResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 15 };
enum { k_iCallback = k_iClientUGCCallbacks + 15 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; AppId_t m_nAppID;
AppId_t m_nAppID;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to GetAppDependencies. Callback may be called // Purpose: The result of a call to GetAppDependencies. Callback may be called
// multiple times until all app dependencies have been returned. // multiple times until all app dependencies have been returned.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GetAppDependenciesResult_t struct GetAppDependenciesResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 16 };
enum { k_iCallback = k_iClientUGCCallbacks + 16 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId; AppId_t m_rgAppIDs[32];
AppId_t m_rgAppIDs[32]; uint32 m_nNumAppDependencies; // number returned in this struct
uint32 m_nNumAppDependencies; // number returned in this struct uint32 m_nTotalNumAppDependencies; // total found
uint32 m_nTotalNumAppDependencies; // total found
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The result of a call to DeleteItem // Purpose: The result of a call to DeleteItem
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct DeleteItemResult_t struct DeleteItemResult_t {
{ enum { k_iCallback = k_iClientUGCCallbacks + 17 };
enum { k_iCallback = k_iClientUGCCallbacks + 17 }; EResult m_eResult;
EResult m_eResult; PublishedFileId_t m_nPublishedFileId;
PublishedFileId_t m_nPublishedFileId;
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMUGC_H #endif // ISTEAMUGC_H

View File

@ -16,208 +16,206 @@
// Purpose: Functions for accessing and manipulating a steam account // Purpose: Functions for accessing and manipulating a steam account
// associated with one client instance // associated with one client instance
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamUser class ISteamUser {
{
public: public:
// returns the HSteamUser this interface represents // returns the HSteamUser this interface represents
// this is only used internally by the API, and by a few select interfaces that support multi-user // this is only used internally by the API, and by a few select interfaces that support multi-user
virtual HSteamUser GetHSteamUser() = 0; virtual HSteamUser GetHSteamUser() = 0;
// returns true if the Steam client current has a live connection to the Steam servers. // returns true if the Steam client current has a live connection to the Steam servers.
// If false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server is down/busy. // If false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server is down/busy.
// The Steam client will automatically be trying to recreate the connection as often as possible. // The Steam client will automatically be trying to recreate the connection as often as possible.
virtual bool BLoggedOn() = 0; virtual bool BLoggedOn() = 0;
// returns the CSteamID of the account currently logged into the Steam client // returns the CSteamID of the account currently logged into the Steam client
// a CSteamID is a unique identifier for an account, and used to differentiate users in all parts of the Steamworks API // a CSteamID is a unique identifier for an account, and used to differentiate users in all parts of the Steamworks API
virtual CSteamID GetSteamID() = 0; virtual CSteamID GetSteamID() = 0;
// Multiplayer Authentication functions // Multiplayer Authentication functions
// InitiateGameConnection() starts the state machine for authenticating the game client with the game server
// It is the client portion of a three-way handshake between the client, the game server, and the steam servers
//
// Parameters:
// void *pAuthBlob - a pointer to empty memory that will be filled in with the authentication token.
// int cbMaxAuthBlob - the number of bytes of allocated memory in pBlob. Should be at least 2048 bytes.
// CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client
// CGameID gameID - the ID of the current game. For games without mods, this is just CGameID( <appID> )
// uint32 unIPServer, uint16 usPortServer - the IP address of the game server
// bool bSecure - whether or not the client thinks that the game server is reporting itself as secure (i.e. VAC is running)
//
// return value - returns the number of bytes written to pBlob. If the return is 0, then the buffer passed in was too small, and the call has failed
// The contents of pBlob should then be sent to the game server, for it to use to complete the authentication process.
virtual int InitiateGameConnection( void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure ) = 0;
// notify of disconnect // InitiateGameConnection() starts the state machine for authenticating the game client with the game server
// needs to occur when the game client leaves the specified game server, needs to match with the InitiateGameConnection() call // It is the client portion of a three-way handshake between the client, the game server, and the steam servers
virtual void TerminateGameConnection( uint32 unIPServer, uint16 usPortServer ) = 0; //
// Parameters:
// void *pAuthBlob - a pointer to empty memory that will be filled in with the authentication token.
// int cbMaxAuthBlob - the number of bytes of allocated memory in pBlob. Should be at least 2048 bytes.
// CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client
// CGameID gameID - the ID of the current game. For games without mods, this is just CGameID( <appID> )
// uint32 unIPServer, uint16 usPortServer - the IP address of the game server
// bool bSecure - whether or not the client thinks that the game server is reporting itself as secure (i.e. VAC is running)
//
// return value - returns the number of bytes written to pBlob. If the return is 0, then the buffer passed in was too small, and the call has failed
// The contents of pBlob should then be sent to the game server, for it to use to complete the authentication process.
virtual int InitiateGameConnection(void* pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure) = 0;
// Legacy functions // notify of disconnect
// needs to occur when the game client leaves the specified game server, needs to match with the InitiateGameConnection() call
virtual void TerminateGameConnection(uint32 unIPServer, uint16 usPortServer) = 0;
// used by only a few games to track usage events // Legacy functions
virtual void TrackAppUsageEvent( CGameID gameID, int eAppUsageEvent, const char *pchExtraInfo = "" ) = 0;
// get the local storage folder for current Steam account to write application data, e.g. save games, configs etc. // used by only a few games to track usage events
// this will usually be something like "C:\Progam Files\Steam\userdata\<SteamID>\<AppID>\local" virtual void TrackAppUsageEvent(CGameID gameID, int eAppUsageEvent, const char* pchExtraInfo = "") = 0;
virtual bool GetUserDataFolder( char *pchBuffer, int cubBuffer ) = 0;
// Starts voice recording. Once started, use GetVoice() to get the data // get the local storage folder for current Steam account to write application data, e.g. save games, configs etc.
virtual void StartVoiceRecording( ) = 0; // this will usually be something like "C:\Progam Files\Steam\userdata\<SteamID>\<AppID>\local"
virtual bool GetUserDataFolder(char* pchBuffer, int cubBuffer) = 0;
// Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for // Starts voice recording. Once started, use GetVoice() to get the data
// a little bit after this function is called. GetVoice() should continue to be called until it returns virtual void StartVoiceRecording() = 0;
// k_eVoiceResultNotRecording
virtual void StopVoiceRecording( ) = 0;
// Determine the size of captured audio data that is available from GetVoice. // Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for
// Most applications will only use compressed data and should ignore the other // a little bit after this function is called. GetVoice() should continue to be called until it returns
// parameters, which exist primarily for backwards compatibility. See comments // k_eVoiceResultNotRecording
// below for further explanation of "uncompressed" data. virtual void StopVoiceRecording() = 0;
virtual EVoiceResult GetAvailableVoice( uint32 *pcbCompressed, uint32 *pcbUncompressed_Deprecated = 0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated = 0 ) = 0;
// --------------------------------------------------------------------------- // Determine the size of captured audio data that is available from GetVoice.
// NOTE: "uncompressed" audio is a deprecated feature and should not be used // Most applications will only use compressed data and should ignore the other
// by most applications. It is raw single-channel 16-bit PCM wave data which // parameters, which exist primarily for backwards compatibility. See comments
// may have been run through preprocessing filters and/or had silence removed, // below for further explanation of "uncompressed" data.
// so the uncompressed audio could have a shorter duration than you expect. virtual EVoiceResult GetAvailableVoice(uint32* pcbCompressed, uint32* pcbUncompressed_Deprecated = 0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated = 0) = 0;
// There may be no data at all during long periods of silence. Also, fetching
// uncompressed audio will cause GetVoice to discard any leftover compressed
// audio, so you must fetch both types at once. Finally, GetAvailableVoice is
// not precisely accurate when the uncompressed size is requested. So if you
// really need to use uncompressed audio, you should call GetVoice frequently
// with two very large (20kb+) output buffers instead of trying to allocate
// perfectly-sized buffers. But most applications should ignore all of these
// details and simply leave the "uncompressed" parameters as NULL/zero.
// ---------------------------------------------------------------------------
// Read captured audio data from the microphone buffer. This should be called // ---------------------------------------------------------------------------
// at least once per frame, and preferably every few milliseconds, to keep the // NOTE: "uncompressed" audio is a deprecated feature and should not be used
// microphone input delay as low as possible. Most applications will only use // by most applications. It is raw single-channel 16-bit PCM wave data which
// compressed data and should pass NULL/zero for the "uncompressed" parameters. // may have been run through preprocessing filters and/or had silence removed,
// Compressed data can be transmitted by your application and decoded into raw // so the uncompressed audio could have a shorter duration than you expect.
// using the DecompressVoice function below. // There may be no data at all during long periods of silence. Also, fetching
virtual EVoiceResult GetVoice( bool bWantCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, bool bWantUncompressed_Deprecated = false, void *pUncompressedDestBuffer_Deprecated = 0, uint32 cbUncompressedDestBufferSize_Deprecated = 0, uint32 *nUncompressBytesWritten_Deprecated = 0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated = 0 ) = 0; // uncompressed audio will cause GetVoice to discard any leftover compressed
// audio, so you must fetch both types at once. Finally, GetAvailableVoice is
// not precisely accurate when the uncompressed size is requested. So if you
// really need to use uncompressed audio, you should call GetVoice frequently
// with two very large (20kb+) output buffers instead of trying to allocate
// perfectly-sized buffers. But most applications should ignore all of these
// details and simply leave the "uncompressed" parameters as NULL/zero.
// ---------------------------------------------------------------------------
// Decodes the compressed voice data returned by GetVoice. The output data is // Read captured audio data from the microphone buffer. This should be called
// raw single-channel 16-bit PCM audio. The decoder supports any sample rate // at least once per frame, and preferably every few milliseconds, to keep the
// from 11025 to 48000; see GetVoiceOptimalSampleRate() below for details. // microphone input delay as low as possible. Most applications will only use
// If the output buffer is not large enough, then *nBytesWritten will be set // compressed data and should pass NULL/zero for the "uncompressed" parameters.
// to the required buffer size, and k_EVoiceResultBufferTooSmall is returned. // Compressed data can be transmitted by your application and decoded into raw
// It is suggested to start with a 20kb buffer and reallocate as necessary. // using the DecompressVoice function below.
virtual EVoiceResult DecompressVoice( const void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, uint32 nDesiredSampleRate ) = 0; virtual EVoiceResult GetVoice(bool bWantCompressed, void* pDestBuffer, uint32 cbDestBufferSize, uint32* nBytesWritten, bool bWantUncompressed_Deprecated = false, void* pUncompressedDestBuffer_Deprecated = 0, uint32 cbUncompressedDestBufferSize_Deprecated = 0, uint32* nUncompressBytesWritten_Deprecated = 0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated = 0) = 0;
// This returns the native sample rate of the Steam voice decompressor; using // Decodes the compressed voice data returned by GetVoice. The output data is
// this sample rate for DecompressVoice will perform the least CPU processing. // raw single-channel 16-bit PCM audio. The decoder supports any sample rate
// However, the final audio quality will depend on how well the audio device // from 11025 to 48000; see GetVoiceOptimalSampleRate() below for details.
// (and/or your application's audio output SDK) deals with lower sample rates. // If the output buffer is not large enough, then *nBytesWritten will be set
// You may find that you get the best audio output quality when you ignore // to the required buffer size, and k_EVoiceResultBufferTooSmall is returned.
// this function and use the native sample rate of your audio output device, // It is suggested to start with a 20kb buffer and reallocate as necessary.
// which is usually 48000 or 44100. virtual EVoiceResult DecompressVoice(const void* pCompressed, uint32 cbCompressed, void* pDestBuffer, uint32 cbDestBufferSize, uint32* nBytesWritten, uint32 nDesiredSampleRate) = 0;
virtual uint32 GetVoiceOptimalSampleRate() = 0;
// Retrieve ticket to be sent to the entity who wishes to authenticate you. // This returns the native sample rate of the Steam voice decompressor; using
// pcbTicket retrieves the length of the actual ticket. // this sample rate for DecompressVoice will perform the least CPU processing.
virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0; // However, the final audio quality will depend on how well the audio device
// (and/or your application's audio output SDK) deals with lower sample rates.
// You may find that you get the best audio output quality when you ignore
// this function and use the native sample rate of your audio output device,
// which is usually 48000 or 44100.
virtual uint32 GetVoiceOptimalSampleRate() = 0;
// Authenticate ticket from entity steamID to be sure it is valid and isnt reused // Retrieve ticket to be sent to the entity who wishes to authenticate you.
// Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse ) // pcbTicket retrieves the length of the actual ticket.
virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0; virtual HAuthTicket GetAuthSessionTicket(void* pTicket, int cbMaxTicket, uint32* pcbTicket) = 0;
// Stop tracking started by BeginAuthSession - called when no longer playing game with this entity // Authenticate ticket from entity steamID to be sure it is valid and isnt reused
virtual void EndAuthSession( CSteamID steamID ) = 0; // Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )
virtual EBeginAuthSessionResult BeginAuthSession(const void* pAuthTicket, int cbAuthTicket, CSteamID steamID) = 0;
// Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to // Stop tracking started by BeginAuthSession - called when no longer playing game with this entity
virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0; virtual void EndAuthSession(CSteamID steamID) = 0;
// After receiving a user's authentication data, and passing it to BeginAuthSession, use this function // Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to
// to determine if the user owns downloadable content specified by the provided AppID. virtual void CancelAuthTicket(HAuthTicket hAuthTicket) = 0;
virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0;
// returns true if this users looks like they are behind a NAT device. Only valid once the user has connected to steam
// (i.e a SteamServersConnected_t has been issued) and may not catch all forms of NAT.
virtual bool BIsBehindNAT() = 0;
// set data to be replicated to friends so that they can join your game // After receiving a user's authentication data, and passing it to BeginAuthSession, use this function
// CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client // to determine if the user owns downloadable content specified by the provided AppID.
// uint32 unIPServer, uint16 usPortServer - the IP address of the game server virtual EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID) = 0;
virtual void AdvertiseGame( CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer ) = 0;
// Requests a ticket encrypted with an app specific shared key // returns true if this users looks like they are behind a NAT device. Only valid once the user has connected to steam
// pDataToInclude, cbDataToInclude will be encrypted into the ticket // (i.e a SteamServersConnected_t has been issued) and may not catch all forms of NAT.
// ( This is asynchronous, you must wait for the ticket to be completed by the server ) virtual bool BIsBehindNAT() = 0;
STEAM_CALL_RESULT( EncryptedAppTicketResponse_t )
virtual SteamAPICall_t RequestEncryptedAppTicket( void *pDataToInclude, int cbDataToInclude ) = 0;
// Retrieves a finished ticket. // set data to be replicated to friends so that they can join your game
// If no ticket is available, or your buffer is too small, returns false. // CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client
// Upon exit, *pcbTicket will be either the size of the ticket copied into your buffer // uint32 unIPServer, uint16 usPortServer - the IP address of the game server
// (if true was returned), or the size needed (if false was returned). To determine the virtual void AdvertiseGame(CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer) = 0;
// proper size of the ticket, you can pass pTicket=NULL and cbMaxTicket=0; if a ticket
// is available, *pcbTicket will contain the size needed, otherwise it will be zero.
virtual bool GetEncryptedAppTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0;
// Trading Card badges data access // Requests a ticket encrypted with an app specific shared key
// if you only have one set of cards, the series will be 1 // pDataToInclude, cbDataToInclude will be encrypted into the ticket
// the user has can have two different badges for a series; the regular (max level 5) and the foil (max level 1) // ( This is asynchronous, you must wait for the ticket to be completed by the server )
virtual int GetGameBadgeLevel( int nSeries, bool bFoil ) = 0; STEAM_CALL_RESULT(EncryptedAppTicketResponse_t)
virtual SteamAPICall_t RequestEncryptedAppTicket(void* pDataToInclude, int cbDataToInclude) = 0;
// gets the Steam Level of the user, as shown on their profile // Retrieves a finished ticket.
virtual int GetPlayerSteamLevel() = 0; // If no ticket is available, or your buffer is too small, returns false.
// Upon exit, *pcbTicket will be either the size of the ticket copied into your buffer
// (if true was returned), or the size needed (if false was returned). To determine the
// proper size of the ticket, you can pass pTicket=NULL and cbMaxTicket=0; if a ticket
// is available, *pcbTicket will contain the size needed, otherwise it will be zero.
virtual bool GetEncryptedAppTicket(void* pTicket, int cbMaxTicket, uint32* pcbTicket) = 0;
// Requests a URL which authenticates an in-game browser for store check-out, // Trading Card badges data access
// and then redirects to the specified URL. As long as the in-game browser // if you only have one set of cards, the series will be 1
// accepts and handles session cookies, Steam microtransaction checkout pages // the user has can have two different badges for a series; the regular (max level 5) and the foil (max level 1)
// will automatically recognize the user instead of presenting a login page. virtual int GetGameBadgeLevel(int nSeries, bool bFoil) = 0;
// The result of this API call will be a StoreAuthURLResponse_t callback.
// NOTE: The URL has a very short lifetime to prevent history-snooping attacks,
// so you should only call this API when you are about to launch the browser,
// or else immediately navigate to the result URL using a hidden browser window.
// NOTE 2: The resulting authorization cookie has an expiration time of one day,
// so it would be a good idea to request and visit a new auth URL every 12 hours.
STEAM_CALL_RESULT( StoreAuthURLResponse_t )
virtual SteamAPICall_t RequestStoreAuthURL( const char *pchRedirectURL ) = 0;
// gets whether the users phone number is verified // gets the Steam Level of the user, as shown on their profile
virtual bool BIsPhoneVerified() = 0; virtual int GetPlayerSteamLevel() = 0;
// gets whether the user has two factor enabled on their account // Requests a URL which authenticates an in-game browser for store check-out,
virtual bool BIsTwoFactorEnabled() = 0; // and then redirects to the specified URL. As long as the in-game browser
// accepts and handles session cookies, Steam microtransaction checkout pages
// will automatically recognize the user instead of presenting a login page.
// The result of this API call will be a StoreAuthURLResponse_t callback.
// NOTE: The URL has a very short lifetime to prevent history-snooping attacks,
// so you should only call this API when you are about to launch the browser,
// or else immediately navigate to the result URL using a hidden browser window.
// NOTE 2: The resulting authorization cookie has an expiration time of one day,
// so it would be a good idea to request and visit a new auth URL every 12 hours.
STEAM_CALL_RESULT(StoreAuthURLResponse_t)
virtual SteamAPICall_t RequestStoreAuthURL(const char* pchRedirectURL) = 0;
// gets whether the users phone number is identifying // gets whether the users phone number is verified
virtual bool BIsPhoneIdentifying() = 0; virtual bool BIsPhoneVerified() = 0;
// gets whether the users phone number is awaiting (re)verification // gets whether the user has two factor enabled on their account
virtual bool BIsPhoneRequiringVerification() = 0; virtual bool BIsTwoFactorEnabled() = 0;
STEAM_CALL_RESULT( MarketEligibilityResponse_t ) // gets whether the users phone number is identifying
virtual SteamAPICall_t GetMarketEligibility() = 0; virtual bool BIsPhoneIdentifying() = 0;
// Retrieves anti indulgence / duration control for current user // gets whether the users phone number is awaiting (re)verification
STEAM_CALL_RESULT( DurationControl_t ) virtual bool BIsPhoneRequiringVerification() = 0;
virtual SteamAPICall_t GetDurationControl() = 0;
// Advise steam china duration control system about the online state of the game. STEAM_CALL_RESULT(MarketEligibilityResponse_t)
// This will prevent offline gameplay time from counting against a user's virtual SteamAPICall_t GetMarketEligibility() = 0;
// playtime limits.
virtual bool BSetDurationControlOnlineState( EDurationControlOnlineState eNewState ) = 0;
// Retrieves anti indulgence / duration control for current user
STEAM_CALL_RESULT(DurationControl_t)
virtual SteamAPICall_t GetDurationControl() = 0;
// Advise steam china duration control system about the online state of the game.
// This will prevent offline gameplay time from counting against a user's
// playtime limits.
virtual bool BSetDurationControlOnlineState(EDurationControlOnlineState eNewState) = 0;
}; };
#define STEAMUSER_INTERFACE_VERSION "SteamUser021" #define STEAMUSER_INTERFACE_VERSION "SteamUser021"
// Global interface accessor // Global interface accessor
inline ISteamUser *SteamUser(); inline ISteamUser* SteamUser();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamUser *, SteamUser, STEAMUSER_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamUser*, SteamUser, STEAMUSER_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when a connections to the Steam back-end has been established // Purpose: called when a connections to the Steam back-end has been established
@ -226,159 +224,135 @@ STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamUser *, SteamUser, STEAMUSER_INTERFA
// only be seen if the user has dropped connection due to a networking issue // only be seen if the user has dropped connection due to a networking issue
// or a Steam server update // or a Steam server update
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamServersConnected_t struct SteamServersConnected_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 1 };
enum { k_iCallback = k_iSteamUserCallbacks + 1 };
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when a connection attempt has failed // Purpose: called when a connection attempt has failed
// this will occur periodically if the Steam client is not connected, // this will occur periodically if the Steam client is not connected,
// and has failed in it's retry to establish a connection // and has failed in it's retry to establish a connection
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamServerConnectFailure_t struct SteamServerConnectFailure_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 2 };
enum { k_iCallback = k_iSteamUserCallbacks + 2 }; EResult m_eResult;
EResult m_eResult; bool m_bStillRetrying;
bool m_bStillRetrying;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called if the client has lost connection to the Steam servers // Purpose: called if the client has lost connection to the Steam servers
// real-time services will be disabled until a matching SteamServersConnected_t has been posted // real-time services will be disabled until a matching SteamServersConnected_t has been posted
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamServersDisconnected_t struct SteamServersDisconnected_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 3 };
enum { k_iCallback = k_iSteamUserCallbacks + 3 }; EResult m_eResult;
EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Sent by the Steam server to the client telling it to disconnect from the specified game server, // Purpose: Sent by the Steam server to the client telling it to disconnect from the specified game server,
// which it may be in the process of or already connected to. // which it may be in the process of or already connected to.
// The game client should immediately disconnect upon receiving this message. // The game client should immediately disconnect upon receiving this message.
// This can usually occur if the user doesn't have rights to play on the game server. // This can usually occur if the user doesn't have rights to play on the game server.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct ClientGameServerDeny_t struct ClientGameServerDeny_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 13 };
enum { k_iCallback = k_iSteamUserCallbacks + 13 };
uint32 m_uAppID; uint32 m_uAppID;
uint32 m_unGameServerIP; uint32 m_unGameServerIP;
uint16 m_usGameServerPort; uint16 m_usGameServerPort;
uint16 m_bSecure; uint16 m_bSecure;
uint32 m_uReason; uint32 m_uReason;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when the callback system for this client is in an error state (and has flushed pending callbacks) // Purpose: called when the callback system for this client is in an error state (and has flushed pending callbacks)
// When getting this message the client should disconnect from Steam, reset any stored Steam state and reconnect. // When getting this message the client should disconnect from Steam, reset any stored Steam state and reconnect.
// This usually occurs in the rare event the Steam client has some kind of fatal error. // This usually occurs in the rare event the Steam client has some kind of fatal error.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct IPCFailure_t struct IPCFailure_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 17 };
enum { k_iCallback = k_iSteamUserCallbacks + 17 }; enum EFailureType {
enum EFailureType k_EFailureFlushedCallbackQueue,
{ k_EFailurePipeFail,
k_EFailureFlushedCallbackQueue, };
k_EFailurePipeFail, uint8 m_eFailureType;
};
uint8 m_eFailureType;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Signaled whenever licenses change // Purpose: Signaled whenever licenses change
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LicensesUpdated_t struct LicensesUpdated_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 25 };
enum { k_iCallback = k_iSteamUserCallbacks + 25 };
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// callback for BeginAuthSession // callback for BeginAuthSession
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct ValidateAuthTicketResponse_t struct ValidateAuthTicketResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 43 };
enum { k_iCallback = k_iSteamUserCallbacks + 43 }; CSteamID m_SteamID;
CSteamID m_SteamID; EAuthSessionResponse m_eAuthSessionResponse;
EAuthSessionResponse m_eAuthSessionResponse; CSteamID m_OwnerSteamID; // different from m_SteamID if borrowed
CSteamID m_OwnerSteamID; // different from m_SteamID if borrowed
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when a user has responded to a microtransaction authorization request // Purpose: called when a user has responded to a microtransaction authorization request
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct MicroTxnAuthorizationResponse_t struct MicroTxnAuthorizationResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 52 };
enum { k_iCallback = k_iSteamUserCallbacks + 52 };
uint32 m_unAppID; // AppID for this microtransaction
uint64 m_ulOrderID; // OrderID provided for the microtransaction
uint8 m_bAuthorized; // if user authorized transaction
};
uint32 m_unAppID; // AppID for this microtransaction
uint64 m_ulOrderID; // OrderID provided for the microtransaction
uint8 m_bAuthorized; // if user authorized transaction
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Result from RequestEncryptedAppTicket // Purpose: Result from RequestEncryptedAppTicket
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct EncryptedAppTicketResponse_t struct EncryptedAppTicketResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 54 };
enum { k_iCallback = k_iSteamUserCallbacks + 54 };
EResult m_eResult; EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// callback for GetAuthSessionTicket // callback for GetAuthSessionTicket
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GetAuthSessionTicketResponse_t struct GetAuthSessionTicketResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 63 };
enum { k_iCallback = k_iSteamUserCallbacks + 63 }; HAuthTicket m_hAuthTicket;
HAuthTicket m_hAuthTicket; EResult m_eResult;
EResult m_eResult;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: sent to your game in response to a steam://gamewebcallback/ command // Purpose: sent to your game in response to a steam://gamewebcallback/ command
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GameWebCallback_t struct GameWebCallback_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 64 };
enum { k_iCallback = k_iSteamUserCallbacks + 64 }; char m_szURL[256];
char m_szURL[256];
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: sent to your game in response to ISteamUser::RequestStoreAuthURL // Purpose: sent to your game in response to ISteamUser::RequestStoreAuthURL
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct StoreAuthURLResponse_t struct StoreAuthURLResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 65 };
enum { k_iCallback = k_iSteamUserCallbacks + 65 }; char m_szURL[512];
char m_szURL[512];
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: sent in response to ISteamUser::GetMarketEligibility // Purpose: sent in response to ISteamUser::GetMarketEligibility
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct MarketEligibilityResponse_t struct MarketEligibilityResponse_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 66 };
enum { k_iCallback = k_iSteamUserCallbacks + 66 }; bool m_bAllowed;
bool m_bAllowed; EMarketNotAllowedReasonFlags m_eNotAllowedReason;
EMarketNotAllowedReasonFlags m_eNotAllowedReason; RTime32 m_rtAllowedAtTime;
RTime32 m_rtAllowedAtTime;
int m_cdaySteamGuardRequiredDays; // The number of days any user is required to have had Steam Guard before they can use the market int m_cdaySteamGuardRequiredDays; // The number of days any user is required to have had Steam Guard before they can use the market
int m_cdayNewDeviceCooldown; // The number of days after initial device authorization a user must wait before using the market on that device int m_cdayNewDeviceCooldown; // The number of days after initial device authorization a user must wait before using the market on that device
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: sent for games with enabled anti indulgence / duration control, for // Purpose: sent for games with enabled anti indulgence / duration control, for
// enabled users. Lets the game know whether the user can keep playing or // enabled users. Lets the game know whether the user can keep playing or
@ -387,24 +361,22 @@ struct MarketEligibilityResponse_t
// This callback is fired asynchronously in response to timers triggering. // This callback is fired asynchronously in response to timers triggering.
// It is also fired in response to calls to GetDurationControl(). // It is also fired in response to calls to GetDurationControl().
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct DurationControl_t struct DurationControl_t {
{ enum { k_iCallback = k_iSteamUserCallbacks + 67 };
enum { k_iCallback = k_iSteamUserCallbacks + 67 };
EResult m_eResult; // result of call (always k_EResultOK for asynchronous timer-based notifications) EResult m_eResult; // result of call (always k_EResultOK for asynchronous timer-based notifications)
AppId_t m_appid; // appid generating playtime AppId_t m_appid; // appid generating playtime
bool m_bApplicable; // is duration control applicable to user + game combination bool m_bApplicable; // is duration control applicable to user + game combination
int32 m_csecsLast5h; // playtime since most recent 5 hour gap in playtime, only counting up to regulatory limit of playtime, in seconds int32 m_csecsLast5h; // playtime since most recent 5 hour gap in playtime, only counting up to regulatory limit of playtime, in seconds
EDurationControlProgress m_progress; // recommended progress (either everything is fine, or please exit game) EDurationControlProgress m_progress; // recommended progress (either everything is fine, or please exit game)
EDurationControlNotification m_notification; // notification to show, if any (always k_EDurationControlNotification_None for API calls) EDurationControlNotification m_notification; // notification to show, if any (always k_EDurationControlNotification_None for API calls)
int32 m_csecsToday; // playtime on current calendar day int32 m_csecsToday; // playtime on current calendar day
int32 m_csecsRemaining; // playtime remaining until the user hits a regulatory limit int32 m_csecsRemaining; // playtime remaining until the user hits a regulatory limit
}; };
#pragma pack(pop)
#pragma pack( pop )
#endif // ISTEAMUSER_H #endif // ISTEAMUSER_H

View File

@ -1,6 +1,6 @@
//====== Copyright <20> 1996-2009, Valve Corporation, All rights reserved. ======= //====== Copyright <20> 1996-2009, Valve Corporation, All rights reserved. =======
// //
// Purpose: interface to stats, achievements, and leaderboards // Purpose: interface to stats, achievements, and leaderboards
// //
//============================================================================= //=============================================================================
@ -10,8 +10,8 @@
#pragma once #pragma once
#endif #endif
#include "steam_api_common.h"
#include "isteamremotestorage.h" #include "isteamremotestorage.h"
#include "steam_api_common.h"
// size limit on stat or achievement name (UTF-8 encoded) // size limit on stat or achievement name (UTF-8 encoded)
enum { k_cchStatNameMax = 128 }; enum { k_cchStatNameMax = 128 };
@ -29,460 +29,425 @@ typedef uint64 SteamLeaderboard_t;
typedef uint64 SteamLeaderboardEntries_t; typedef uint64 SteamLeaderboardEntries_t;
// type of data request, when downloading leaderboard entries // type of data request, when downloading leaderboard entries
enum ELeaderboardDataRequest enum ELeaderboardDataRequest {
{ k_ELeaderboardDataRequestGlobal = 0,
k_ELeaderboardDataRequestGlobal = 0, k_ELeaderboardDataRequestGlobalAroundUser = 1,
k_ELeaderboardDataRequestGlobalAroundUser = 1, k_ELeaderboardDataRequestFriends = 2,
k_ELeaderboardDataRequestFriends = 2, k_ELeaderboardDataRequestUsers = 3
k_ELeaderboardDataRequestUsers = 3
}; };
// the sort order of a leaderboard // the sort order of a leaderboard
enum ELeaderboardSortMethod enum ELeaderboardSortMethod {
{ k_ELeaderboardSortMethodNone = 0,
k_ELeaderboardSortMethodNone = 0, k_ELeaderboardSortMethodAscending = 1, // top-score is lowest number
k_ELeaderboardSortMethodAscending = 1, // top-score is lowest number k_ELeaderboardSortMethodDescending = 2, // top-score is highest number
k_ELeaderboardSortMethodDescending = 2, // top-score is highest number
}; };
// the display type (used by the Steam Community web site) for a leaderboard // the display type (used by the Steam Community web site) for a leaderboard
enum ELeaderboardDisplayType enum ELeaderboardDisplayType {
{ k_ELeaderboardDisplayTypeNone = 0,
k_ELeaderboardDisplayTypeNone = 0, k_ELeaderboardDisplayTypeNumeric = 1, // simple numerical score
k_ELeaderboardDisplayTypeNumeric = 1, // simple numerical score k_ELeaderboardDisplayTypeTimeSeconds = 2, // the score represents a time, in seconds
k_ELeaderboardDisplayTypeTimeSeconds = 2, // the score represents a time, in seconds k_ELeaderboardDisplayTypeTimeMilliSeconds = 3, // the score represents a time, in milliseconds
k_ELeaderboardDisplayTypeTimeMilliSeconds = 3, // the score represents a time, in milliseconds
}; };
enum ELeaderboardUploadScoreMethod enum ELeaderboardUploadScoreMethod {
{ k_ELeaderboardUploadScoreMethodNone = 0,
k_ELeaderboardUploadScoreMethodNone = 0, k_ELeaderboardUploadScoreMethodKeepBest = 1, // Leaderboard will keep user's best score
k_ELeaderboardUploadScoreMethodKeepBest = 1, // Leaderboard will keep user's best score k_ELeaderboardUploadScoreMethodForceUpdate = 2, // Leaderboard will always replace score with specified
k_ELeaderboardUploadScoreMethodForceUpdate = 2, // Leaderboard will always replace score with specified
}; };
// a single entry in a leaderboard, as returned by GetDownloadedLeaderboardEntry() // a single entry in a leaderboard, as returned by GetDownloadedLeaderboardEntry()
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
struct LeaderboardEntry_t struct LeaderboardEntry_t {
{ CSteamID m_steamIDUser; // user with the entry - use SteamFriends()->GetFriendPersonaName() & SteamFriends()->GetFriendAvatar() to get more info
CSteamID m_steamIDUser; // user with the entry - use SteamFriends()->GetFriendPersonaName() & SteamFriends()->GetFriendAvatar() to get more info int32 m_nGlobalRank; // [1..N], where N is the number of users with an entry in the leaderboard
int32 m_nGlobalRank; // [1..N], where N is the number of users with an entry in the leaderboard int32 m_nScore; // score as set in the leaderboard
int32 m_nScore; // score as set in the leaderboard int32 m_cDetails; // number of int32 details available for this entry
int32 m_cDetails; // number of int32 details available for this entry UGCHandle_t m_hUGC; // handle for UGC attached to the entry
UGCHandle_t m_hUGC; // handle for UGC attached to the entry
}; };
#pragma pack( pop ) #pragma pack(pop)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Functions for accessing stats, achievements, and leaderboard information // Purpose: Functions for accessing stats, achievements, and leaderboard information
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamUserStats class ISteamUserStats {
{
public: public:
// Ask the server to send down this user's data and achievements for this game // Ask the server to send down this user's data and achievements for this game
STEAM_CALL_BACK( UserStatsReceived_t ) STEAM_CALL_BACK(UserStatsReceived_t)
virtual bool RequestCurrentStats() = 0; virtual bool RequestCurrentStats() = 0;
// Data accessors // Data accessors
STEAM_FLAT_NAME( GetStatInt32 ) STEAM_FLAT_NAME(GetStatInt32)
virtual bool GetStat( const char *pchName, int32 *pData ) = 0; virtual bool GetStat(const char* pchName, int32* pData) = 0;
STEAM_FLAT_NAME( GetStatFloat ) STEAM_FLAT_NAME(GetStatFloat)
virtual bool GetStat( const char *pchName, float *pData ) = 0; virtual bool GetStat(const char* pchName, float* pData) = 0;
// Set / update data // Set / update data
STEAM_FLAT_NAME( SetStatInt32 ) STEAM_FLAT_NAME(SetStatInt32)
virtual bool SetStat( const char *pchName, int32 nData ) = 0; virtual bool SetStat(const char* pchName, int32 nData) = 0;
STEAM_FLAT_NAME( SetStatFloat ) STEAM_FLAT_NAME(SetStatFloat)
virtual bool SetStat( const char *pchName, float fData ) = 0; virtual bool SetStat(const char* pchName, float fData) = 0;
virtual bool UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dSessionLength ) = 0; virtual bool UpdateAvgRateStat(const char* pchName, float flCountThisSession, double dSessionLength) = 0;
// Achievement flag accessors // Achievement flag accessors
virtual bool GetAchievement( const char *pchName, bool *pbAchieved ) = 0; virtual bool GetAchievement(const char* pchName, bool* pbAchieved) = 0;
virtual bool SetAchievement( const char *pchName ) = 0; virtual bool SetAchievement(const char* pchName) = 0;
virtual bool ClearAchievement( const char *pchName ) = 0; virtual bool ClearAchievement(const char* pchName) = 0;
// Get the achievement status, and the time it was unlocked if unlocked. // Get the achievement status, and the time it was unlocked if unlocked.
// If the return value is true, but the unlock time is zero, that means it was unlocked before Steam // If the return value is true, but the unlock time is zero, that means it was unlocked before Steam
// began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970. // began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970.
virtual bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32 *punUnlockTime ) = 0; virtual bool GetAchievementAndUnlockTime(const char* pchName, bool* pbAchieved, uint32* punUnlockTime) = 0;
// Store the current data on the server, will get a callback when set // Store the current data on the server, will get a callback when set
// And one callback for every new achievement // And one callback for every new achievement
// //
// If the callback has a result of k_EResultInvalidParam, one or more stats // If the callback has a result of k_EResultInvalidParam, one or more stats
// uploaded has been rejected, either because they broke constraints // uploaded has been rejected, either because they broke constraints
// or were out of date. In this case the server sends back updated values. // or were out of date. In this case the server sends back updated values.
// The stats should be re-iterated to keep in sync. // The stats should be re-iterated to keep in sync.
virtual bool StoreStats() = 0; virtual bool StoreStats() = 0;
// Achievement / GroupAchievement metadata // Achievement / GroupAchievement metadata
// Gets the icon of the achievement, which is a handle to be used in ISteamUtils::GetImageRGBA(), or 0 if none set. // Gets the icon of the achievement, which is a handle to be used in ISteamUtils::GetImageRGBA(), or 0 if none set.
// A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback // A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback
// which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the // which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the
// specified achievement. // specified achievement.
virtual int GetAchievementIcon( const char *pchName ) = 0; virtual int GetAchievementIcon(const char* pchName) = 0;
// Get general attributes for an achievement. Accepts the following keys: // Get general attributes for an achievement. Accepts the following keys:
// - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8) // - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8)
// - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden) // - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden)
virtual const char *GetAchievementDisplayAttribute( const char *pchName, const char *pchKey ) = 0; virtual const char* GetAchievementDisplayAttribute(const char* pchName, const char* pchKey) = 0;
// Achievement progress - triggers an AchievementProgress callback, that is all. // Achievement progress - triggers an AchievementProgress callback, that is all.
// Calling this w/ N out of N progress will NOT set the achievement, the game must still do that. // Calling this w/ N out of N progress will NOT set the achievement, the game must still do that.
virtual bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress ) = 0; virtual bool IndicateAchievementProgress(const char* pchName, uint32 nCurProgress, uint32 nMaxProgress) = 0;
// Used for iterating achievements. In general games should not need these functions because they should have a // Used for iterating achievements. In general games should not need these functions because they should have a
// list of existing achievements compiled into them // list of existing achievements compiled into them
virtual uint32 GetNumAchievements() = 0; virtual uint32 GetNumAchievements() = 0;
// Get achievement name iAchievement in [0,GetNumAchievements) // Get achievement name iAchievement in [0,GetNumAchievements)
virtual const char *GetAchievementName( uint32 iAchievement ) = 0; virtual const char* GetAchievementName(uint32 iAchievement) = 0;
// Friends stats & achievements // Friends stats & achievements
// downloads stats for the user // downloads stats for the user
// returns a UserStatsReceived_t received when completed // returns a UserStatsReceived_t received when completed
// if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail // if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail
// these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data // these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data
STEAM_CALL_RESULT( UserStatsReceived_t ) STEAM_CALL_RESULT(UserStatsReceived_t)
virtual SteamAPICall_t RequestUserStats( CSteamID steamIDUser ) = 0; virtual SteamAPICall_t RequestUserStats(CSteamID steamIDUser) = 0;
// requests stat information for a user, usable after a successful call to RequestUserStats() // requests stat information for a user, usable after a successful call to RequestUserStats()
STEAM_FLAT_NAME( GetUserStatInt32 ) STEAM_FLAT_NAME(GetUserStatInt32)
virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) = 0; virtual bool GetUserStat(CSteamID steamIDUser, const char* pchName, int32* pData) = 0;
STEAM_FLAT_NAME( GetUserStatFloat ) STEAM_FLAT_NAME(GetUserStatFloat)
virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) = 0; virtual bool GetUserStat(CSteamID steamIDUser, const char* pchName, float* pData) = 0;
virtual bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved ) = 0; virtual bool GetUserAchievement(CSteamID steamIDUser, const char* pchName, bool* pbAchieved) = 0;
// See notes for GetAchievementAndUnlockTime above // See notes for GetAchievementAndUnlockTime above
virtual bool GetUserAchievementAndUnlockTime( CSteamID steamIDUser, const char *pchName, bool *pbAchieved, uint32 *punUnlockTime ) = 0; virtual bool GetUserAchievementAndUnlockTime(CSteamID steamIDUser, const char* pchName, bool* pbAchieved, uint32* punUnlockTime) = 0;
// Reset stats // Reset stats
virtual bool ResetAllStats( bool bAchievementsToo ) = 0; virtual bool ResetAllStats(bool bAchievementsToo) = 0;
// Leaderboard functions // Leaderboard functions
// asks the Steam back-end for a leaderboard by name, and will create it if it's not yet // asks the Steam back-end for a leaderboard by name, and will create it if it's not yet
// This call is asynchronous, with the result returned in LeaderboardFindResult_t // This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT(LeaderboardFindResult_t) STEAM_CALL_RESULT(LeaderboardFindResult_t)
virtual SteamAPICall_t FindOrCreateLeaderboard( const char *pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType ) = 0; virtual SteamAPICall_t FindOrCreateLeaderboard(const char* pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType) = 0;
// as above, but won't create the leaderboard if it's not found // as above, but won't create the leaderboard if it's not found
// This call is asynchronous, with the result returned in LeaderboardFindResult_t // This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT( LeaderboardFindResult_t ) STEAM_CALL_RESULT(LeaderboardFindResult_t)
virtual SteamAPICall_t FindLeaderboard( const char *pchLeaderboardName ) = 0; virtual SteamAPICall_t FindLeaderboard(const char* pchLeaderboardName) = 0;
// returns the name of a leaderboard // returns the name of a leaderboard
virtual const char *GetLeaderboardName( SteamLeaderboard_t hSteamLeaderboard ) = 0; virtual const char* GetLeaderboardName(SteamLeaderboard_t hSteamLeaderboard) = 0;
// returns the total number of entries in a leaderboard, as of the last request // returns the total number of entries in a leaderboard, as of the last request
virtual int GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard ) = 0; virtual int GetLeaderboardEntryCount(SteamLeaderboard_t hSteamLeaderboard) = 0;
// returns the sort method of the leaderboard // returns the sort method of the leaderboard
virtual ELeaderboardSortMethod GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard ) = 0; virtual ELeaderboardSortMethod GetLeaderboardSortMethod(SteamLeaderboard_t hSteamLeaderboard) = 0;
// returns the display type of the leaderboard // returns the display type of the leaderboard
virtual ELeaderboardDisplayType GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard ) = 0; virtual ELeaderboardDisplayType GetLeaderboardDisplayType(SteamLeaderboard_t hSteamLeaderboard) = 0;
// Asks the Steam back-end for a set of rows in the leaderboard. // Asks the Steam back-end for a set of rows in the leaderboard.
// This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t // This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t
// LeaderboardScoresDownloaded_t will contain a handle to pull the results from GetDownloadedLeaderboardEntries() (below) // LeaderboardScoresDownloaded_t will contain a handle to pull the results from GetDownloadedLeaderboardEntries() (below)
// You can ask for more entries than exist, and it will return as many as do exist. // You can ask for more entries than exist, and it will return as many as do exist.
// k_ELeaderboardDataRequestGlobal requests rows in the leaderboard from the full table, with nRangeStart & nRangeEnd in the range [1, TotalEntries] // k_ELeaderboardDataRequestGlobal requests rows in the leaderboard from the full table, with nRangeStart & nRangeEnd in the range [1, TotalEntries]
// k_ELeaderboardDataRequestGlobalAroundUser requests rows around the current user, nRangeStart being negate // k_ELeaderboardDataRequestGlobalAroundUser requests rows around the current user, nRangeStart being negate
// e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after // e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after
// k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user // k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user
STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t ) STEAM_CALL_RESULT(LeaderboardScoresDownloaded_t)
virtual SteamAPICall_t DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd ) = 0; virtual SteamAPICall_t DownloadLeaderboardEntries(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd) = 0;
// as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers // as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers
// if a user doesn't have a leaderboard entry, they won't be included in the result // if a user doesn't have a leaderboard entry, they won't be included in the result
// a max of 100 users can be downloaded at a time, with only one outstanding call at a time // a max of 100 users can be downloaded at a time, with only one outstanding call at a time
STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers) STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers)
STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t ) STEAM_CALL_RESULT(LeaderboardScoresDownloaded_t)
virtual SteamAPICall_t DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard, virtual SteamAPICall_t DownloadLeaderboardEntriesForUsers(SteamLeaderboard_t hSteamLeaderboard,
STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID *prgUsers, int cUsers ) = 0; STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID* prgUsers, int cUsers)
= 0;
// Returns data about a single leaderboard entry // Returns data about a single leaderboard entry
// use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries // use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries
// e.g. // e.g.
// void OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *pLeaderboardScoresDownloaded ) // void OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *pLeaderboardScoresDownloaded )
// { // {
// for ( int index = 0; index < pLeaderboardScoresDownloaded->m_cEntryCount; index++ ) // for ( int index = 0; index < pLeaderboardScoresDownloaded->m_cEntryCount; index++ )
// { // {
// LeaderboardEntry_t leaderboardEntry; // LeaderboardEntry_t leaderboardEntry;
// int32 details[3]; // we know this is how many we've stored previously // int32 details[3]; // we know this is how many we've stored previously
// GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded->m_hSteamLeaderboardEntries, index, &leaderboardEntry, details, 3 ); // GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded->m_hSteamLeaderboardEntries, index, &leaderboardEntry, details, 3 );
// assert( leaderboardEntry.m_cDetails == 3 ); // assert( leaderboardEntry.m_cDetails == 3 );
// ... // ...
// } // }
// once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid // once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid
virtual bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t *pLeaderboardEntry, int32 *pDetails, int cDetailsMax ) = 0; virtual bool GetDownloadedLeaderboardEntry(SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t* pLeaderboardEntry, int32* pDetails, int cDetailsMax) = 0;
// Uploads a user score to the Steam back-end. // Uploads a user score to the Steam back-end.
// This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t // This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t
// Details are extra game-defined information regarding how the user got that score // Details are extra game-defined information regarding how the user got that score
// pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list // pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list
STEAM_CALL_RESULT( LeaderboardScoreUploaded_t ) STEAM_CALL_RESULT(LeaderboardScoreUploaded_t)
virtual SteamAPICall_t UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32 *pScoreDetails, int cScoreDetailsCount ) = 0; virtual SteamAPICall_t UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32* pScoreDetails, int cScoreDetailsCount) = 0;
// Attaches a piece of user generated content the user's entry on a leaderboard. // Attaches a piece of user generated content the user's entry on a leaderboard.
// hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare(). // hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare().
// This call is asynchronous, with the result returned in LeaderboardUGCSet_t. // This call is asynchronous, with the result returned in LeaderboardUGCSet_t.
STEAM_CALL_RESULT( LeaderboardUGCSet_t ) STEAM_CALL_RESULT(LeaderboardUGCSet_t)
virtual SteamAPICall_t AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC ) = 0; virtual SteamAPICall_t AttachLeaderboardUGC(SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC) = 0;
// Retrieves the number of players currently playing your game (online + offline) // Retrieves the number of players currently playing your game (online + offline)
// This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t // This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t
STEAM_CALL_RESULT( NumberOfCurrentPlayers_t ) STEAM_CALL_RESULT(NumberOfCurrentPlayers_t)
virtual SteamAPICall_t GetNumberOfCurrentPlayers() = 0; virtual SteamAPICall_t GetNumberOfCurrentPlayers() = 0;
// Requests that Steam fetch data on the percentage of players who have received each achievement // Requests that Steam fetch data on the percentage of players who have received each achievement
// for the game globally. // for the game globally.
// This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t. // This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t.
STEAM_CALL_RESULT( GlobalAchievementPercentagesReady_t ) STEAM_CALL_RESULT(GlobalAchievementPercentagesReady_t)
virtual SteamAPICall_t RequestGlobalAchievementPercentages() = 0; virtual SteamAPICall_t RequestGlobalAchievementPercentages() = 0;
// Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch // Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch
// the next most achieved afterwards. Will return -1 if there is no data on achievement // the next most achieved afterwards. Will return -1 if there is no data on achievement
// percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback). // percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback).
virtual int GetMostAchievedAchievementInfo( char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved ) = 0; virtual int GetMostAchievedAchievementInfo(char* pchName, uint32 unNameBufLen, float* pflPercent, bool* pbAchieved) = 0;
// Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another // Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another
// GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last // GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last
// achievement has been iterated. // achievement has been iterated.
virtual int GetNextMostAchievedAchievementInfo( int iIteratorPrevious, char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved ) = 0; virtual int GetNextMostAchievedAchievementInfo(int iIteratorPrevious, char* pchName, uint32 unNameBufLen, float* pflPercent, bool* pbAchieved) = 0;
// Returns the percentage of users who have achieved the specified achievement. // Returns the percentage of users who have achieved the specified achievement.
virtual bool GetAchievementAchievedPercent( const char *pchName, float *pflPercent ) = 0; virtual bool GetAchievementAchievedPercent(const char* pchName, float* pflPercent) = 0;
// Requests global stats data, which is available for stats marked as "aggregated". // Requests global stats data, which is available for stats marked as "aggregated".
// This call is asynchronous, with the results returned in GlobalStatsReceived_t. // This call is asynchronous, with the results returned in GlobalStatsReceived_t.
// nHistoryDays specifies how many days of day-by-day history to retrieve in addition // nHistoryDays specifies how many days of day-by-day history to retrieve in addition
// to the overall totals. The limit is 60. // to the overall totals. The limit is 60.
STEAM_CALL_RESULT( GlobalStatsReceived_t ) STEAM_CALL_RESULT(GlobalStatsReceived_t)
virtual SteamAPICall_t RequestGlobalStats( int nHistoryDays ) = 0; virtual SteamAPICall_t RequestGlobalStats(int nHistoryDays) = 0;
// Gets the lifetime totals for an aggregated stat // Gets the lifetime totals for an aggregated stat
STEAM_FLAT_NAME( GetGlobalStatInt64 ) STEAM_FLAT_NAME(GetGlobalStatInt64)
virtual bool GetGlobalStat( const char *pchStatName, int64 *pData ) = 0; virtual bool GetGlobalStat(const char* pchStatName, int64* pData) = 0;
STEAM_FLAT_NAME( GetGlobalStatDouble ) STEAM_FLAT_NAME(GetGlobalStatDouble)
virtual bool GetGlobalStat( const char *pchStatName, double *pData ) = 0; virtual bool GetGlobalStat(const char* pchStatName, double* pData) = 0;
// Gets history for an aggregated stat. pData will be filled with daily values, starting with today. // Gets history for an aggregated stat. pData will be filled with daily values, starting with today.
// So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago, // So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago,
// etc. cubData is the size in bytes of the pubData buffer. Returns the number of // etc. cubData is the size in bytes of the pubData buffer. Returns the number of
// elements actually set. // elements actually set.
STEAM_FLAT_NAME( GetGlobalStatHistoryInt64 ) STEAM_FLAT_NAME(GetGlobalStatHistoryInt64)
virtual int32 GetGlobalStatHistory( const char *pchStatName, STEAM_ARRAY_COUNT(cubData) int64 *pData, uint32 cubData ) = 0; virtual int32 GetGlobalStatHistory(const char* pchStatName, STEAM_ARRAY_COUNT(cubData) int64* pData, uint32 cubData) = 0;
STEAM_FLAT_NAME( GetGlobalStatHistoryDouble ) STEAM_FLAT_NAME(GetGlobalStatHistoryDouble)
virtual int32 GetGlobalStatHistory( const char *pchStatName, STEAM_ARRAY_COUNT(cubData) double *pData, uint32 cubData ) = 0; virtual int32 GetGlobalStatHistory(const char* pchStatName, STEAM_ARRAY_COUNT(cubData) double* pData, uint32 cubData) = 0;
// For achievements that have related Progress stats, use this to query what the bounds of that progress are. // For achievements that have related Progress stats, use this to query what the bounds of that progress are.
// You may want this info to selectively call IndicateAchievementProgress when appropriate milestones of progress // You may want this info to selectively call IndicateAchievementProgress when appropriate milestones of progress
// have been made, to show a progress notification to the user. // have been made, to show a progress notification to the user.
STEAM_FLAT_NAME( GetAchievementProgressLimitsInt32 ) STEAM_FLAT_NAME(GetAchievementProgressLimitsInt32)
virtual bool GetAchievementProgressLimits( const char *pchName, int32 *pnMinProgress, int32 *pnMaxProgress ) = 0; virtual bool GetAchievementProgressLimits(const char* pchName, int32* pnMinProgress, int32* pnMaxProgress) = 0;
STEAM_FLAT_NAME( GetAchievementProgressLimitsFloat )
virtual bool GetAchievementProgressLimits( const char *pchName, float *pfMinProgress, float *pfMaxProgress ) = 0;
STEAM_FLAT_NAME(GetAchievementProgressLimitsFloat)
virtual bool GetAchievementProgressLimits(const char* pchName, float* pfMinProgress, float* pfMaxProgress) = 0;
}; };
#define STEAMUSERSTATS_INTERFACE_VERSION "STEAMUSERSTATS_INTERFACE_VERSION012" #define STEAMUSERSTATS_INTERFACE_VERSION "STEAMUSERSTATS_INTERFACE_VERSION012"
// Global interface accessor // Global interface accessor
inline ISteamUserStats *SteamUserStats(); inline ISteamUserStats* SteamUserStats();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamUserStats *, SteamUserStats, STEAMUSERSTATS_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamUserStats*, SteamUserStats, STEAMUSERSTATS_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when the latests stats and achievements have been received // Purpose: called when the latests stats and achievements have been received
// from the server // from the server
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct UserStatsReceived_t struct UserStatsReceived_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 1 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 1 }; uint64 m_nGameID; // Game these stats are for
uint64 m_nGameID; // Game these stats are for EResult m_eResult; // Success / error fetching the stats
EResult m_eResult; // Success / error fetching the stats CSteamID m_steamIDUser; // The user for whom the stats are retrieved for
CSteamID m_steamIDUser; // The user for whom the stats are retrieved for
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result of a request to store the user stats for a game // Purpose: result of a request to store the user stats for a game
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct UserStatsStored_t struct UserStatsStored_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 2 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 2 }; uint64 m_nGameID; // Game these stats are for
uint64 m_nGameID; // Game these stats are for EResult m_eResult; // success / error
EResult m_eResult; // success / error
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: result of a request to store the achievements for a game, or an // Purpose: result of a request to store the achievements for a game, or an
// "indicate progress" call. If both m_nCurProgress and m_nMaxProgress // "indicate progress" call. If both m_nCurProgress and m_nMaxProgress
// are zero, that means the achievement has been fully unlocked. // are zero, that means the achievement has been fully unlocked.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct UserAchievementStored_t struct UserAchievementStored_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 3 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 3 };
uint64 m_nGameID; // Game this is for uint64 m_nGameID; // Game this is for
bool m_bGroupAchievement; // if this is a "group" achievement bool m_bGroupAchievement; // if this is a "group" achievement
char m_rgchAchievementName[k_cchStatNameMax]; // name of the achievement char m_rgchAchievementName[k_cchStatNameMax]; // name of the achievement
uint32 m_nCurProgress; // current progress towards the achievement uint32 m_nCurProgress; // current progress towards the achievement
uint32 m_nMaxProgress; // "out of" this many uint32 m_nMaxProgress; // "out of" this many
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: call result for finding a leaderboard, returned as a result of FindOrCreateLeaderboard() or FindLeaderboard() // Purpose: call result for finding a leaderboard, returned as a result of FindOrCreateLeaderboard() or FindLeaderboard()
// use CCallResult<> to map this async result to a member function // use CCallResult<> to map this async result to a member function
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LeaderboardFindResult_t struct LeaderboardFindResult_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 4 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 4 }; SteamLeaderboard_t m_hSteamLeaderboard; // handle to the leaderboard serarched for, 0 if no leaderboard found
SteamLeaderboard_t m_hSteamLeaderboard; // handle to the leaderboard serarched for, 0 if no leaderboard found uint8 m_bLeaderboardFound; // 0 if no leaderboard found
uint8 m_bLeaderboardFound; // 0 if no leaderboard found
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: call result indicating scores for a leaderboard have been downloaded and are ready to be retrieved, returned as a result of DownloadLeaderboardEntries() // Purpose: call result indicating scores for a leaderboard have been downloaded and are ready to be retrieved, returned as a result of DownloadLeaderboardEntries()
// use CCallResult<> to map this async result to a member function // use CCallResult<> to map this async result to a member function
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LeaderboardScoresDownloaded_t struct LeaderboardScoresDownloaded_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 5 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 5 }; SteamLeaderboard_t m_hSteamLeaderboard;
SteamLeaderboard_t m_hSteamLeaderboard; SteamLeaderboardEntries_t m_hSteamLeaderboardEntries; // the handle to pass into GetDownloadedLeaderboardEntries()
SteamLeaderboardEntries_t m_hSteamLeaderboardEntries; // the handle to pass into GetDownloadedLeaderboardEntries() int m_cEntryCount; // the number of entries downloaded
int m_cEntryCount; // the number of entries downloaded
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: call result indicating scores has been uploaded, returned as a result of UploadLeaderboardScore() // Purpose: call result indicating scores has been uploaded, returned as a result of UploadLeaderboardScore()
// use CCallResult<> to map this async result to a member function // use CCallResult<> to map this async result to a member function
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LeaderboardScoreUploaded_t struct LeaderboardScoreUploaded_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 6 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 6 }; uint8 m_bSuccess; // 1 if the call was successful
uint8 m_bSuccess; // 1 if the call was successful SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was
SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was int32 m_nScore; // the score that was attempted to set
int32 m_nScore; // the score that was attempted to set uint8 m_bScoreChanged; // true if the score in the leaderboard change, false if the existing score was better
uint8 m_bScoreChanged; // true if the score in the leaderboard change, false if the existing score was better int m_nGlobalRankNew; // the new global rank of the user in this leaderboard
int m_nGlobalRankNew; // the new global rank of the user in this leaderboard int m_nGlobalRankPrevious; // the previous global rank of the user in this leaderboard; 0 if the user had no existing entry in the leaderboard
int m_nGlobalRankPrevious; // the previous global rank of the user in this leaderboard; 0 if the user had no existing entry in the leaderboard
}; };
struct NumberOfCurrentPlayers_t struct NumberOfCurrentPlayers_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 7 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 7 }; uint8 m_bSuccess; // 1 if the call was successful
uint8 m_bSuccess; // 1 if the call was successful int32 m_cPlayers; // Number of players currently playing
int32 m_cPlayers; // Number of players currently playing
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback indicating that a user's stats have been unloaded. // Purpose: Callback indicating that a user's stats have been unloaded.
// Call RequestUserStats again to access stats for this user // Call RequestUserStats again to access stats for this user
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct UserStatsUnloaded_t struct UserStatsUnloaded_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 }; CSteamID m_steamIDUser; // User whose stats have been unloaded
CSteamID m_steamIDUser; // User whose stats have been unloaded
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback indicating that an achievement icon has been fetched // Purpose: Callback indicating that an achievement icon has been fetched
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct UserAchievementIconFetched_t struct UserAchievementIconFetched_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 9 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 9 };
CGameID m_nGameID; // Game this is for CGameID m_nGameID; // Game this is for
char m_rgchAchievementName[k_cchStatNameMax]; // name of the achievement char m_rgchAchievementName[k_cchStatNameMax]; // name of the achievement
bool m_bAchieved; // Is the icon for the achieved or not achieved version? bool m_bAchieved; // Is the icon for the achieved or not achieved version?
int m_nIconHandle; // Handle to the image, which can be used in SteamUtils()->GetImageRGBA(), 0 means no image is set for the achievement int m_nIconHandle; // Handle to the image, which can be used in SteamUtils()->GetImageRGBA(), 0 means no image is set for the achievement
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Callback indicating that global achievement percentages are fetched // Purpose: Callback indicating that global achievement percentages are fetched
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GlobalAchievementPercentagesReady_t struct GlobalAchievementPercentagesReady_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 10 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 10 };
uint64 m_nGameID; // Game this is for uint64 m_nGameID; // Game this is for
EResult m_eResult; // Result of the operation EResult m_eResult; // Result of the operation
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: call result indicating UGC has been uploaded, returned as a result of SetLeaderboardUGC() // Purpose: call result indicating UGC has been uploaded, returned as a result of SetLeaderboardUGC()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LeaderboardUGCSet_t struct LeaderboardUGCSet_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 11 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 11 }; EResult m_eResult; // The result of the operation
EResult m_eResult; // The result of the operation SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was
SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: callback indicating that PS3 trophies have been installed // Purpose: callback indicating that PS3 trophies have been installed
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct PS3TrophiesInstalled_t struct PS3TrophiesInstalled_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 }; uint64 m_nGameID; // Game these stats are for
uint64 m_nGameID; // Game these stats are for EResult m_eResult; // The result of the operation
EResult m_eResult; // The result of the operation uint64 m_ulRequiredDiskSpace; // If m_eResult is k_EResultDiskFull, will contain the amount of space needed to install trophies
uint64 m_ulRequiredDiskSpace; // If m_eResult is k_EResultDiskFull, will contain the amount of space needed to install trophies
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: callback indicating global stats have been received. // Purpose: callback indicating global stats have been received.
// Returned as a result of RequestGlobalStats() // Returned as a result of RequestGlobalStats()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GlobalStatsReceived_t struct GlobalStatsReceived_t {
{ enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 };
enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 }; uint64 m_nGameID; // Game global stats were requested for
uint64 m_nGameID; // Game global stats were requested for EResult m_eResult; // The result of the request
EResult m_eResult; // The result of the request
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMUSER_H #endif // ISTEAMUSER_H

View File

@ -12,294 +12,272 @@
#include "steam_api_common.h" #include "steam_api_common.h"
// Steam API call failure results // Steam API call failure results
enum ESteamAPICallFailure enum ESteamAPICallFailure {
{ k_ESteamAPICallFailureNone = -1, // no failure
k_ESteamAPICallFailureNone = -1, // no failure k_ESteamAPICallFailureSteamGone = 0, // the local Steam process has gone away
k_ESteamAPICallFailureSteamGone = 0, // the local Steam process has gone away k_ESteamAPICallFailureNetworkFailure = 1, // the network connection to Steam has been broken, or was already broken
k_ESteamAPICallFailureNetworkFailure = 1, // the network connection to Steam has been broken, or was already broken // SteamServersDisconnected_t callback will be sent around the same time
// SteamServersDisconnected_t callback will be sent around the same time // SteamServersConnected_t will be sent when the client is able to talk to the Steam servers again
// SteamServersConnected_t will be sent when the client is able to talk to the Steam servers again k_ESteamAPICallFailureInvalidHandle = 2, // the SteamAPICall_t handle passed in no longer exists
k_ESteamAPICallFailureInvalidHandle = 2, // the SteamAPICall_t handle passed in no longer exists k_ESteamAPICallFailureMismatchedCallback = 3, // GetAPICallResult() was called with the wrong callback type for this API call
k_ESteamAPICallFailureMismatchedCallback = 3,// GetAPICallResult() was called with the wrong callback type for this API call
}; };
// Input modes for the Big Picture gamepad text entry // Input modes for the Big Picture gamepad text entry
enum EGamepadTextInputMode enum EGamepadTextInputMode {
{ k_EGamepadTextInputModeNormal = 0,
k_EGamepadTextInputModeNormal = 0, k_EGamepadTextInputModePassword = 1
k_EGamepadTextInputModePassword = 1
}; };
// Controls number of allowed lines for the Big Picture gamepad text entry // Controls number of allowed lines for the Big Picture gamepad text entry
enum EGamepadTextInputLineMode enum EGamepadTextInputLineMode {
{ k_EGamepadTextInputLineModeSingleLine = 0,
k_EGamepadTextInputLineModeSingleLine = 0, k_EGamepadTextInputLineModeMultipleLines = 1
k_EGamepadTextInputLineModeMultipleLines = 1
}; };
// The context where text filtering is being done // The context where text filtering is being done
enum ETextFilteringContext enum ETextFilteringContext {
{ k_ETextFilteringContextUnknown = 0, // Unknown context
k_ETextFilteringContextUnknown = 0, // Unknown context k_ETextFilteringContextGameContent = 1, // Game content, only legally required filtering is performed
k_ETextFilteringContextGameContent = 1, // Game content, only legally required filtering is performed k_ETextFilteringContextChat = 2, // Chat from another player
k_ETextFilteringContextChat = 2, // Chat from another player k_ETextFilteringContextName = 3, // Character or item name
k_ETextFilteringContextName = 3, // Character or item name
}; };
// function prototype for warning message hook // function prototype for warning message hook
#if defined( POSIX ) #if defined(POSIX)
#define __cdecl #define __cdecl
#endif #endif
extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *); extern "C" typedef void(__cdecl* SteamAPIWarningMessageHook_t)(int, const char*);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: interface to user independent utility functions // Purpose: interface to user independent utility functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamUtils class ISteamUtils {
{
public: public:
// return the number of seconds since the user // return the number of seconds since the user
virtual uint32 GetSecondsSinceAppActive() = 0; virtual uint32 GetSecondsSinceAppActive() = 0;
virtual uint32 GetSecondsSinceComputerActive() = 0; virtual uint32 GetSecondsSinceComputerActive() = 0;
// the universe this client is connecting to // the universe this client is connecting to
virtual EUniverse GetConnectedUniverse() = 0; virtual EUniverse GetConnectedUniverse() = 0;
// Steam server time. Number of seconds since January 1, 1970, GMT (i.e unix time) // Steam server time. Number of seconds since January 1, 1970, GMT (i.e unix time)
virtual uint32 GetServerRealTime() = 0; virtual uint32 GetServerRealTime() = 0;
// returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database) // returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database)
// e.g "US" or "UK". // e.g "US" or "UK".
virtual const char *GetIPCountry() = 0; virtual const char* GetIPCountry() = 0;
// returns true if the image exists, and valid sizes were filled out // returns true if the image exists, and valid sizes were filled out
virtual bool GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight ) = 0; virtual bool GetImageSize(int iImage, uint32* pnWidth, uint32* pnHeight) = 0;
// returns true if the image exists, and the buffer was successfully filled out // returns true if the image exists, and the buffer was successfully filled out
// results are returned in RGBA format // results are returned in RGBA format
// the destination buffer size should be 4 * height * width * sizeof(char) // the destination buffer size should be 4 * height * width * sizeof(char)
virtual bool GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize ) = 0; virtual bool GetImageRGBA(int iImage, uint8* pubDest, int nDestBufferSize) = 0;
// Deprecated. Do not call this. // Deprecated. Do not call this.
STEAM_PRIVATE_API( virtual bool GetCSERIPPort( uint32 *unIP, uint16 *usPort ) = 0; ) STEAM_PRIVATE_API(virtual bool GetCSERIPPort(uint32* unIP, uint16* usPort) = 0;)
// return the amount of battery power left in the current system in % [0..100], 255 for being on AC power // return the amount of battery power left in the current system in % [0..100], 255 for being on AC power
virtual uint8 GetCurrentBatteryPower() = 0; virtual uint8 GetCurrentBatteryPower() = 0;
// returns the appID of the current process // returns the appID of the current process
virtual uint32 GetAppID() = 0; virtual uint32 GetAppID() = 0;
// Sets the position where the overlay instance for the currently calling game should show notifications. // Sets the position where the overlay instance for the currently calling game should show notifications.
// This position is per-game and if this function is called from outside of a game context it will do nothing. // This position is per-game and if this function is called from outside of a game context it will do nothing.
virtual void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition ) = 0; virtual void SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition) = 0;
// API asynchronous call results // API asynchronous call results
// can be used directly, but more commonly used via the callback dispatch API (see steam_api.h) // can be used directly, but more commonly used via the callback dispatch API (see steam_api.h)
virtual bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall, bool *pbFailed ) = 0; virtual bool IsAPICallCompleted(SteamAPICall_t hSteamAPICall, bool* pbFailed) = 0;
virtual ESteamAPICallFailure GetAPICallFailureReason( SteamAPICall_t hSteamAPICall ) = 0; virtual ESteamAPICallFailure GetAPICallFailureReason(SteamAPICall_t hSteamAPICall) = 0;
virtual bool GetAPICallResult( SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed ) = 0; virtual bool GetAPICallResult(SteamAPICall_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed) = 0;
// Deprecated. Applications should use SteamAPI_RunCallbacks() instead. Game servers do not need to call this function. // Deprecated. Applications should use SteamAPI_RunCallbacks() instead. Game servers do not need to call this function.
STEAM_PRIVATE_API( virtual void RunFrame() = 0; ) STEAM_PRIVATE_API(virtual void RunFrame() = 0;)
// returns the number of IPC calls made since the last time this function was called // returns the number of IPC calls made since the last time this function was called
// Used for perf debugging so you can understand how many IPC calls your game makes per frame // Used for perf debugging so you can understand how many IPC calls your game makes per frame
// Every IPC call is at minimum a thread context switch if not a process one so you want to rate // Every IPC call is at minimum a thread context switch if not a process one so you want to rate
// control how often you do them. // control how often you do them.
virtual uint32 GetIPCCallCount() = 0; virtual uint32 GetIPCCallCount() = 0;
// API warning handling // API warning handling
// 'int' is the severity; 0 for msg, 1 for warning // 'int' is the severity; 0 for msg, 1 for warning
// 'const char *' is the text of the message // 'const char *' is the text of the message
// callbacks will occur directly after the API function is called that generated the warning or message // callbacks will occur directly after the API function is called that generated the warning or message
virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0; virtual void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction) = 0;
// Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to // Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to
// start & hook the game process, so this function will initially return false while the overlay is loading. // start & hook the game process, so this function will initially return false while the overlay is loading.
virtual bool IsOverlayEnabled() = 0; virtual bool IsOverlayEnabled() = 0;
// Normally this call is unneeded if your game has a constantly running frame loop that calls the // Normally this call is unneeded if your game has a constantly running frame loop that calls the
// D3D Present API, or OGL SwapBuffers API every frame. // D3D Present API, or OGL SwapBuffers API every frame.
// //
// However, if you have a game that only refreshes the screen on an event driven basis then that can break // However, if you have a game that only refreshes the screen on an event driven basis then that can break
// the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also // the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also
// need to Present() to the screen any time an even needing a notification happens or when the overlay is // need to Present() to the screen any time an even needing a notification happens or when the overlay is
// brought up over the game by a user. You can use this API to ask the overlay if it currently need a present // brought up over the game by a user. You can use this API to ask the overlay if it currently need a present
// in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you // in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you
// refresh the screen with Present or SwapBuffers to allow the overlay to do it's work. // refresh the screen with Present or SwapBuffers to allow the overlay to do it's work.
virtual bool BOverlayNeedsPresent() = 0; virtual bool BOverlayNeedsPresent() = 0;
// Asynchronous call to check if an executable file has been signed using the public key set on the signing tab // Asynchronous call to check if an executable file has been signed using the public key set on the signing tab
// of the partner site, for example to refuse to load modified executable files. // of the partner site, for example to refuse to load modified executable files.
// The result is returned in CheckFileSignature_t. // The result is returned in CheckFileSignature_t.
// k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function. // k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function.
// k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site. // k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site.
// k_ECheckFileSignatureFileNotFound - The file does not exist on disk. // k_ECheckFileSignatureFileNotFound - The file does not exist on disk.
// k_ECheckFileSignatureInvalidSignature - The file exists, and the signing tab has been set for this file, but the file is either not signed or the signature does not match. // k_ECheckFileSignatureInvalidSignature - The file exists, and the signing tab has been set for this file, but the file is either not signed or the signature does not match.
// k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid. // k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid.
STEAM_CALL_RESULT( CheckFileSignature_t ) STEAM_CALL_RESULT(CheckFileSignature_t)
virtual SteamAPICall_t CheckFileSignature( const char *szFileName ) = 0; virtual SteamAPICall_t CheckFileSignature(const char* szFileName) = 0;
// Activates the Big Picture text input dialog which only supports gamepad input // Activates the Big Picture text input dialog which only supports gamepad input
virtual bool ShowGamepadTextInput( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32 unCharMax, const char *pchExistingText ) = 0; virtual bool ShowGamepadTextInput(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char* pchDescription, uint32 unCharMax, const char* pchExistingText) = 0;
// Returns previously entered text & length // Returns previously entered text & length
virtual uint32 GetEnteredGamepadTextLength() = 0; virtual uint32 GetEnteredGamepadTextLength() = 0;
virtual bool GetEnteredGamepadTextInput( char *pchText, uint32 cchText ) = 0; virtual bool GetEnteredGamepadTextInput(char* pchText, uint32 cchText) = 0;
// returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases // returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases
virtual const char *GetSteamUILanguage() = 0; virtual const char* GetSteamUILanguage() = 0;
// returns true if Steam itself is running in VR mode // returns true if Steam itself is running in VR mode
virtual bool IsSteamRunningInVR() = 0; virtual bool IsSteamRunningInVR() = 0;
// Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.
virtual void SetOverlayNotificationInset( int nHorizontalInset, int nVerticalInset ) = 0;
// returns true if Steam & the Steam Overlay are running in Big Picture mode // Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.
// Games much be launched through the Steam client to enable the Big Picture overlay. During development, virtual void SetOverlayNotificationInset(int nHorizontalInset, int nVerticalInset) = 0;
// a game can be added as a non-steam game to the developers library to test this feature
virtual bool IsSteamInBigPictureMode() = 0;
// ask SteamUI to create and render its OpenVR dashboard // returns true if Steam & the Steam Overlay are running in Big Picture mode
virtual void StartVRDashboard() = 0; // Games much be launched through the Steam client to enable the Big Picture overlay. During development,
// a game can be added as a non-steam game to the developers library to test this feature
virtual bool IsSteamInBigPictureMode() = 0;
// Returns true if the HMD content will be streamed via Steam Remote Play // ask SteamUI to create and render its OpenVR dashboard
virtual bool IsVRHeadsetStreamingEnabled() = 0; virtual void StartVRDashboard() = 0;
// Set whether the HMD content will be streamed via Steam Remote Play // Returns true if the HMD content will be streamed via Steam Remote Play
// If this is set to true, then the scene in the HMD headset will be streamed, and remote input will not be allowed. virtual bool IsVRHeadsetStreamingEnabled() = 0;
// If this is set to false, then the application window will be streamed instead, and remote input will be allowed.
// The default is true unless "VRHeadsetStreaming" "0" is in the extended appinfo for a game.
// (this is useful for games that have asymmetric multiplayer gameplay)
virtual void SetVRHeadsetStreamingEnabled( bool bEnabled ) = 0;
// Returns whether this steam client is a Steam China specific client, vs the global client. // Set whether the HMD content will be streamed via Steam Remote Play
virtual bool IsSteamChinaLauncher() = 0; // If this is set to true, then the scene in the HMD headset will be streamed, and remote input will not be allowed.
// If this is set to false, then the application window will be streamed instead, and remote input will be allowed.
// The default is true unless "VRHeadsetStreaming" "0" is in the extended appinfo for a game.
// (this is useful for games that have asymmetric multiplayer gameplay)
virtual void SetVRHeadsetStreamingEnabled(bool bEnabled) = 0;
// Initializes text filtering, loading dictionaries for the language the game is running in. // Returns whether this steam client is a Steam China specific client, vs the global client.
// unFilterOptions are reserved for future use and should be set to 0 virtual bool IsSteamChinaLauncher() = 0;
// Returns false if filtering is unavailable for the game's language, in which case FilterText() will act as a passthrough.
//
// Users can customize the text filter behavior in their Steam Account preferences:
// https://store.steampowered.com/account/preferences#CommunityContentPreferences
virtual bool InitFilterText( uint32 unFilterOptions = 0 ) = 0;
// Filters the provided input message and places the filtered result into pchOutFilteredText, using legally required filtering and additional filtering based on the context and user settings // Initializes text filtering, loading dictionaries for the language the game is running in.
// eContext is the type of content in the input string // unFilterOptions are reserved for future use and should be set to 0
// sourceSteamID is the Steam ID that is the source of the input string (e.g. the player with the name, or who said the chat text) // Returns false if filtering is unavailable for the game's language, in which case FilterText() will act as a passthrough.
// pchInputText is the input string that should be filtered, which can be ASCII or UTF-8 //
// pchOutFilteredText is where the output will be placed, even if no filtering is performed // Users can customize the text filter behavior in their Steam Account preferences:
// nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText, should be at least strlen(pchInputText)+1 // https://store.steampowered.com/account/preferences#CommunityContentPreferences
// Returns the number of characters (not bytes) filtered virtual bool InitFilterText(uint32 unFilterOptions = 0) = 0;
virtual int FilterText( ETextFilteringContext eContext, CSteamID sourceSteamID, const char *pchInputMessage, char *pchOutFilteredText, uint32 nByteSizeOutFilteredText ) = 0;
// Return what we believe your current ipv6 connectivity to "the internet" is on the specified protocol. // Filters the provided input message and places the filtered result into pchOutFilteredText, using legally required filtering and additional filtering based on the context and user settings
// This does NOT tell you if the Steam client is currently connected to Steam via ipv6. // eContext is the type of content in the input string
virtual ESteamIPv6ConnectivityState GetIPv6ConnectivityState( ESteamIPv6ConnectivityProtocol eProtocol ) = 0; // sourceSteamID is the Steam ID that is the source of the input string (e.g. the player with the name, or who said the chat text)
// pchInputText is the input string that should be filtered, which can be ASCII or UTF-8
// pchOutFilteredText is where the output will be placed, even if no filtering is performed
// nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText, should be at least strlen(pchInputText)+1
// Returns the number of characters (not bytes) filtered
virtual int FilterText(ETextFilteringContext eContext, CSteamID sourceSteamID, const char* pchInputMessage, char* pchOutFilteredText, uint32 nByteSizeOutFilteredText) = 0;
// Return what we believe your current ipv6 connectivity to "the internet" is on the specified protocol.
// This does NOT tell you if the Steam client is currently connected to Steam via ipv6.
virtual ESteamIPv6ConnectivityState GetIPv6ConnectivityState(ESteamIPv6ConnectivityProtocol eProtocol) = 0;
}; };
#define STEAMUTILS_INTERFACE_VERSION "SteamUtils010" #define STEAMUTILS_INTERFACE_VERSION "SteamUtils010"
// Global interface accessor // Global interface accessor
inline ISteamUtils *SteamUtils(); inline ISteamUtils* SteamUtils();
STEAM_DEFINE_INTERFACE_ACCESSOR( ISteamUtils *, SteamUtils, SteamInternal_FindOrCreateUserInterface( 0, STEAMUTILS_INTERFACE_VERSION ), "user", STEAMUTILS_INTERFACE_VERSION ); STEAM_DEFINE_INTERFACE_ACCESSOR(ISteamUtils*, SteamUtils, SteamInternal_FindOrCreateUserInterface(0, STEAMUTILS_INTERFACE_VERSION), "user", STEAMUTILS_INTERFACE_VERSION);
// Global accessor for the gameserver client // Global accessor for the gameserver client
inline ISteamUtils *SteamGameServerUtils(); inline ISteamUtils* SteamGameServerUtils();
STEAM_DEFINE_INTERFACE_ACCESSOR( ISteamUtils *, SteamGameServerUtils, SteamInternal_FindOrCreateGameServerInterface( 0, STEAMUTILS_INTERFACE_VERSION ), "gameserver", STEAMUTILS_INTERFACE_VERSION ); STEAM_DEFINE_INTERFACE_ACCESSOR(ISteamUtils*, SteamGameServerUtils, SteamInternal_FindOrCreateGameServerInterface(0, STEAMUTILS_INTERFACE_VERSION), "gameserver", STEAMUTILS_INTERFACE_VERSION);
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: The country of the user changed // Purpose: The country of the user changed
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct IPCountry_t struct IPCountry_t {
{ enum { k_iCallback = k_iSteamUtilsCallbacks + 1 };
enum { k_iCallback = k_iSteamUtilsCallbacks + 1 };
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Fired when running on a laptop and less than 10 minutes of battery is left, fires then every minute // Purpose: Fired when running on a laptop and less than 10 minutes of battery is left, fires then every minute
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct LowBatteryPower_t struct LowBatteryPower_t {
{ enum { k_iCallback = k_iSteamUtilsCallbacks + 2 };
enum { k_iCallback = k_iSteamUtilsCallbacks + 2 }; uint8 m_nMinutesBatteryLeft;
uint8 m_nMinutesBatteryLeft;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: called when a SteamAsyncCall_t has completed (or failed) // Purpose: called when a SteamAsyncCall_t has completed (or failed)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamAPICallCompleted_t struct SteamAPICallCompleted_t {
{ enum { k_iCallback = k_iSteamUtilsCallbacks + 3 };
enum { k_iCallback = k_iSteamUtilsCallbacks + 3 }; SteamAPICall_t m_hAsyncCall;
SteamAPICall_t m_hAsyncCall; int m_iCallback;
int m_iCallback; uint32 m_cubParam;
uint32 m_cubParam;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// called when Steam wants to shutdown // called when Steam wants to shutdown
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct SteamShutdown_t struct SteamShutdown_t {
{ enum { k_iCallback = k_iSteamUtilsCallbacks + 4 };
enum { k_iCallback = k_iSteamUtilsCallbacks + 4 };
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// results for CheckFileSignature // results for CheckFileSignature
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
enum ECheckFileSignature enum ECheckFileSignature {
{ k_ECheckFileSignatureInvalidSignature = 0,
k_ECheckFileSignatureInvalidSignature = 0, k_ECheckFileSignatureValidSignature = 1,
k_ECheckFileSignatureValidSignature = 1, k_ECheckFileSignatureFileNotFound = 2,
k_ECheckFileSignatureFileNotFound = 2, k_ECheckFileSignatureNoSignaturesFoundForThisApp = 3,
k_ECheckFileSignatureNoSignaturesFoundForThisApp = 3, k_ECheckFileSignatureNoSignaturesFoundForThisFile = 4,
k_ECheckFileSignatureNoSignaturesFoundForThisFile = 4,
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// callback for CheckFileSignature // callback for CheckFileSignature
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct CheckFileSignature_t struct CheckFileSignature_t {
{ enum { k_iCallback = k_iSteamUtilsCallbacks + 5 };
enum { k_iCallback = k_iSteamUtilsCallbacks + 5 }; ECheckFileSignature m_eCheckFileSignature;
ECheckFileSignature m_eCheckFileSignature;
}; };
// k_iSteamUtilsCallbacks + 13 is taken // k_iSteamUtilsCallbacks + 13 is taken
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Big Picture gamepad text input has been closed // Big Picture gamepad text input has been closed
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct GamepadTextInputDismissed_t struct GamepadTextInputDismissed_t {
{ enum { k_iCallback = k_iSteamUtilsCallbacks + 14 };
enum { k_iCallback = k_iSteamUtilsCallbacks + 14 }; bool m_bSubmitted; // true if user entered & accepted text (Call ISteamUtils::GetEnteredGamepadTextInput() for text), false if canceled input
bool m_bSubmitted; // true if user entered & accepted text (Call ISteamUtils::GetEnteredGamepadTextInput() for text), false if canceled input uint32 m_unSubmittedText;
uint32 m_unSubmittedText;
}; };
// k_iSteamUtilsCallbacks + 15 is taken // k_iSteamUtilsCallbacks + 15 is taken
#pragma pack( pop ) #pragma pack(pop)
#endif // ISTEAMUTILS_H #endif // ISTEAMUTILS_H

View File

@ -13,56 +13,48 @@
#include "steam_api_common.h" #include "steam_api_common.h"
// callbacks // callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Steam Video API // Purpose: Steam Video API
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ISteamVideo class ISteamVideo {
{
public: public:
// Get a URL suitable for streaming the given Video app ID's video
virtual void GetVideoURL(AppId_t unVideoAppID) = 0;
// Get a URL suitable for streaming the given Video app ID's video // returns true if user is uploading a live broadcast
virtual void GetVideoURL( AppId_t unVideoAppID ) = 0; virtual bool IsBroadcasting(int* pnNumViewers) = 0;
// returns true if user is uploading a live broadcast // Get the OPF Details for 360 Video Playback
virtual bool IsBroadcasting( int *pnNumViewers ) = 0; STEAM_CALL_BACK(GetOPFSettingsResult_t)
virtual void GetOPFSettings(AppId_t unVideoAppID) = 0;
// Get the OPF Details for 360 Video Playback virtual bool GetOPFStringForApp(AppId_t unVideoAppID, char* pchBuffer, int32* pnBufferSize) = 0;
STEAM_CALL_BACK( GetOPFSettingsResult_t )
virtual void GetOPFSettings( AppId_t unVideoAppID ) = 0;
virtual bool GetOPFStringForApp( AppId_t unVideoAppID, char *pchBuffer, int32 *pnBufferSize ) = 0;
}; };
#define STEAMVIDEO_INTERFACE_VERSION "STEAMVIDEO_INTERFACE_V002" #define STEAMVIDEO_INTERFACE_VERSION "STEAMVIDEO_INTERFACE_V002"
// Global interface accessor // Global interface accessor
inline ISteamVideo *SteamVideo(); inline ISteamVideo* SteamVideo();
STEAM_DEFINE_USER_INTERFACE_ACCESSOR( ISteamVideo *, SteamVideo, STEAMVIDEO_INTERFACE_VERSION ); STEAM_DEFINE_USER_INTERFACE_ACCESSOR(ISteamVideo*, SteamVideo, STEAMVIDEO_INTERFACE_VERSION);
STEAM_CALLBACK_BEGIN( GetVideoURLResult_t, k_iClientVideoCallbacks + 11 ) STEAM_CALLBACK_BEGIN(GetVideoURLResult_t, k_iClientVideoCallbacks + 11)
STEAM_CALLBACK_MEMBER( 0, EResult, m_eResult ) STEAM_CALLBACK_MEMBER(0, EResult, m_eResult)
STEAM_CALLBACK_MEMBER( 1, AppId_t, m_unVideoAppID ) STEAM_CALLBACK_MEMBER(1, AppId_t, m_unVideoAppID)
STEAM_CALLBACK_MEMBER( 2, char, m_rgchURL[256] ) STEAM_CALLBACK_MEMBER(2, char, m_rgchURL[256])
STEAM_CALLBACK_END(3) STEAM_CALLBACK_END(3)
STEAM_CALLBACK_BEGIN(GetOPFSettingsResult_t, k_iClientVideoCallbacks + 24)
STEAM_CALLBACK_BEGIN( GetOPFSettingsResult_t, k_iClientVideoCallbacks + 24 ) STEAM_CALLBACK_MEMBER(0, EResult, m_eResult)
STEAM_CALLBACK_MEMBER( 0, EResult, m_eResult ) STEAM_CALLBACK_MEMBER(1, AppId_t, m_unVideoAppID)
STEAM_CALLBACK_MEMBER( 1, AppId_t, m_unVideoAppID )
STEAM_CALLBACK_END(2) STEAM_CALLBACK_END(2)
#pragma pack(pop)
#pragma pack( pop )
#endif // ISTEAMVIDEO_H #endif // ISTEAMVIDEO_H

View File

@ -1,6 +1,6 @@
//========= Copyright <20> 1996-2008, Valve LLC, All rights reserved. ============ //========= Copyright <20> 1996-2008, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
@ -37,215 +37,209 @@ const int k_cbMaxGameServerGameData = 2048;
/// Actually, the name Key/Value is a bit misleading. The "key" is better /// Actually, the name Key/Value is a bit misleading. The "key" is better
/// understood as "filter operation code" and the "value" is the operand to this /// understood as "filter operation code" and the "value" is the operand to this
/// filter operation. The meaning of the operand depends upon the filter. /// filter operation. The meaning of the operand depends upon the filter.
struct MatchMakingKeyValuePair_t struct MatchMakingKeyValuePair_t {
{ MatchMakingKeyValuePair_t() { m_szKey[0] = m_szValue[0] = 0; }
MatchMakingKeyValuePair_t() { m_szKey[0] = m_szValue[0] = 0; } MatchMakingKeyValuePair_t(const char* pchKey, const char* pchValue)
MatchMakingKeyValuePair_t( const char *pchKey, const char *pchValue ) {
{ strncpy(m_szKey, pchKey, sizeof(m_szKey)); // this is a public header, use basic c library string funcs only!
strncpy( m_szKey, pchKey, sizeof(m_szKey) ); // this is a public header, use basic c library string funcs only! m_szKey[sizeof(m_szKey) - 1] = '\0';
m_szKey[ sizeof( m_szKey ) - 1 ] = '\0'; strncpy(m_szValue, pchValue, sizeof(m_szValue));
strncpy( m_szValue, pchValue, sizeof(m_szValue) ); m_szValue[sizeof(m_szValue) - 1] = '\0';
m_szValue[ sizeof( m_szValue ) - 1 ] = '\0'; }
} char m_szKey[256];
char m_szKey[ 256 ]; char m_szValue[256];
char m_szValue[ 256 ];
}; };
enum EMatchMakingServerResponse {
enum EMatchMakingServerResponse eServerResponded = 0,
{ eServerFailedToRespond,
eServerResponded = 0, eNoServersListedOnMasterServer // for the Internet query type, returned in response callback if no servers of this type match
eServerFailedToRespond,
eNoServersListedOnMasterServer // for the Internet query type, returned in response callback if no servers of this type match
}; };
// servernetadr_t is all the addressing info the serverbrowser needs to know about a game server, // servernetadr_t is all the addressing info the serverbrowser needs to know about a game server,
// namely: its IP, its connection port, and its query port. // namely: its IP, its connection port, and its query port.
class servernetadr_t class servernetadr_t {
{
public: public:
servernetadr_t()
: m_usConnectionPort(0)
, m_usQueryPort(0)
, m_unIP(0)
{
}
servernetadr_t() : m_usConnectionPort( 0 ), m_usQueryPort( 0 ), m_unIP( 0 ) {} void Init(unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort);
void Init( unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort );
#ifdef NETADR_H #ifdef NETADR_H
netadr_t GetIPAndQueryPort(); netadr_t GetIPAndQueryPort();
#endif #endif
// Access the query port.
uint16 GetQueryPort() const;
void SetQueryPort( uint16 usPort );
// Access the connection port. // Access the query port.
uint16 GetConnectionPort() const; uint16 GetQueryPort() const;
void SetConnectionPort( uint16 usPort ); void SetQueryPort(uint16 usPort);
// Access the IP // Access the connection port.
uint32 GetIP() const; uint16 GetConnectionPort() const;
void SetIP( uint32 unIP ); void SetConnectionPort(uint16 usPort);
// This gets the 'a.b.c.d:port' string with the connection port (instead of the query port). // Access the IP
const char *GetConnectionAddressString() const; uint32 GetIP() const;
const char *GetQueryAddressString() const; void SetIP(uint32 unIP);
// Comparison operators and functions. // This gets the 'a.b.c.d:port' string with the connection port (instead of the query port).
bool operator<(const servernetadr_t &netadr) const; const char* GetConnectionAddressString() const;
void operator=( const servernetadr_t &that ) const char* GetQueryAddressString() const;
{
m_usConnectionPort = that.m_usConnectionPort; // Comparison operators and functions.
m_usQueryPort = that.m_usQueryPort; bool operator<(const servernetadr_t& netadr) const;
m_unIP = that.m_unIP; void operator=(const servernetadr_t& that)
} {
m_usConnectionPort = that.m_usConnectionPort;
m_usQueryPort = that.m_usQueryPort;
m_unIP = that.m_unIP;
}
private: private:
const char *ToString( uint32 unIP, uint16 usPort ) const; const char* ToString(uint32 unIP, uint16 usPort) const;
uint16 m_usConnectionPort; // (in HOST byte order) uint16 m_usConnectionPort; // (in HOST byte order)
uint16 m_usQueryPort; uint16 m_usQueryPort;
uint32 m_unIP; uint32 m_unIP;
}; };
inline void servernetadr_t::Init(unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort)
inline void servernetadr_t::Init( unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort )
{ {
m_unIP = ip; m_unIP = ip;
m_usQueryPort = usQueryPort; m_usQueryPort = usQueryPort;
m_usConnectionPort = usConnectionPort; m_usConnectionPort = usConnectionPort;
} }
#ifdef NETADR_H #ifdef NETADR_H
inline netadr_t servernetadr_t::GetIPAndQueryPort() inline netadr_t servernetadr_t::GetIPAndQueryPort()
{ {
return netadr_t( m_unIP, m_usQueryPort ); return netadr_t(m_unIP, m_usQueryPort);
} }
#endif #endif
inline uint16 servernetadr_t::GetQueryPort() const inline uint16 servernetadr_t::GetQueryPort() const
{ {
return m_usQueryPort; return m_usQueryPort;
} }
inline void servernetadr_t::SetQueryPort( uint16 usPort ) inline void servernetadr_t::SetQueryPort(uint16 usPort)
{ {
m_usQueryPort = usPort; m_usQueryPort = usPort;
} }
inline uint16 servernetadr_t::GetConnectionPort() const inline uint16 servernetadr_t::GetConnectionPort() const
{ {
return m_usConnectionPort; return m_usConnectionPort;
} }
inline void servernetadr_t::SetConnectionPort( uint16 usPort ) inline void servernetadr_t::SetConnectionPort(uint16 usPort)
{ {
m_usConnectionPort = usPort; m_usConnectionPort = usPort;
} }
inline uint32 servernetadr_t::GetIP() const inline uint32 servernetadr_t::GetIP() const
{ {
return m_unIP; return m_unIP;
} }
inline void servernetadr_t::SetIP( uint32 unIP ) inline void servernetadr_t::SetIP(uint32 unIP)
{ {
m_unIP = unIP; m_unIP = unIP;
} }
inline const char *servernetadr_t::ToString( uint32 unIP, uint16 usPort ) const inline const char* servernetadr_t::ToString(uint32 unIP, uint16 usPort) const
{ {
static char s[4][64]; static char s[4][64];
static int nBuf = 0; static int nBuf = 0;
unsigned char *ipByte = (unsigned char *)&unIP; unsigned char* ipByte = (unsigned char*)&unIP;
#ifdef VALVE_BIG_ENDIAN #ifdef VALVE_BIG_ENDIAN
_snprintf (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[0]), (int)(ipByte[1]), (int)(ipByte[2]), (int)(ipByte[3]), usPort ); _snprintf(s[nBuf], sizeof(s[nBuf]), "%u.%u.%u.%u:%i", (int)(ipByte[0]), (int)(ipByte[1]), (int)(ipByte[2]), (int)(ipByte[3]), usPort);
#else #else
_snprintf (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[3]), (int)(ipByte[2]), (int)(ipByte[1]), (int)(ipByte[0]), usPort ); _snprintf(s[nBuf], sizeof(s[nBuf]), "%u.%u.%u.%u:%i", (int)(ipByte[3]), (int)(ipByte[2]), (int)(ipByte[1]), (int)(ipByte[0]), usPort);
#endif #endif
const char *pchRet = s[nBuf]; const char* pchRet = s[nBuf];
++nBuf; ++nBuf;
nBuf %= ( (sizeof(s)/sizeof(s[0])) ); nBuf %= ((sizeof(s) / sizeof(s[0])));
return pchRet; return pchRet;
} }
inline const char* servernetadr_t::GetConnectionAddressString() const inline const char* servernetadr_t::GetConnectionAddressString() const
{ {
return ToString( m_unIP, m_usConnectionPort ); return ToString(m_unIP, m_usConnectionPort);
} }
inline const char* servernetadr_t::GetQueryAddressString() const inline const char* servernetadr_t::GetQueryAddressString() const
{ {
return ToString( m_unIP, m_usQueryPort ); return ToString(m_unIP, m_usQueryPort);
} }
inline bool servernetadr_t::operator<(const servernetadr_t &netadr) const inline bool servernetadr_t::operator<(const servernetadr_t& netadr) const
{ {
return ( m_unIP < netadr.m_unIP ) || ( m_unIP == netadr.m_unIP && m_usQueryPort < netadr.m_usQueryPort ); return (m_unIP < netadr.m_unIP) || (m_unIP == netadr.m_unIP && m_usQueryPort < netadr.m_usQueryPort);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Data describing a single server // Purpose: Data describing a single server
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class gameserveritem_t class gameserveritem_t {
{
public: public:
gameserveritem_t(); gameserveritem_t();
const char* GetName() const; const char* GetName() const;
void SetName( const char *pName ); void SetName(const char* pName);
public: public:
servernetadr_t m_NetAdr; ///< IP/Query Port/Connection Port for this server servernetadr_t m_NetAdr; ///< IP/Query Port/Connection Port for this server
int m_nPing; ///< current ping time in milliseconds int m_nPing; ///< current ping time in milliseconds
bool m_bHadSuccessfulResponse; ///< server has responded successfully in the past bool m_bHadSuccessfulResponse; ///< server has responded successfully in the past
bool m_bDoNotRefresh; ///< server is marked as not responding and should no longer be refreshed bool m_bDoNotRefresh; ///< server is marked as not responding and should no longer be refreshed
char m_szGameDir[k_cbMaxGameServerGameDir]; ///< current game directory char m_szGameDir[k_cbMaxGameServerGameDir]; ///< current game directory
char m_szMap[k_cbMaxGameServerMapName]; ///< current map char m_szMap[k_cbMaxGameServerMapName]; ///< current map
char m_szGameDescription[k_cbMaxGameServerGameDescription]; ///< game description char m_szGameDescription[k_cbMaxGameServerGameDescription]; ///< game description
uint32 m_nAppID; ///< Steam App ID of this server uint32 m_nAppID; ///< Steam App ID of this server
int m_nPlayers; ///< total number of players currently on the server. INCLUDES BOTS!! int m_nPlayers; ///< total number of players currently on the server. INCLUDES BOTS!!
int m_nMaxPlayers; ///< Maximum players that can join this server int m_nMaxPlayers; ///< Maximum players that can join this server
int m_nBotPlayers; ///< Number of bots (i.e simulated players) on this server int m_nBotPlayers; ///< Number of bots (i.e simulated players) on this server
bool m_bPassword; ///< true if this server needs a password to join bool m_bPassword; ///< true if this server needs a password to join
bool m_bSecure; ///< Is this server protected by VAC bool m_bSecure; ///< Is this server protected by VAC
uint32 m_ulTimeLastPlayed; ///< time (in unix time) when this server was last played on (for favorite/history servers) uint32 m_ulTimeLastPlayed; ///< time (in unix time) when this server was last played on (for favorite/history servers)
int m_nServerVersion; ///< server version as reported to Steam int m_nServerVersion; ///< server version as reported to Steam
private: private:
/// Game server name
char m_szServerName[k_cbMaxGameServerName];
/// Game server name // For data added after SteamMatchMaking001 add it here
char m_szServerName[k_cbMaxGameServerName];
// For data added after SteamMatchMaking001 add it here
public: public:
/// the tags this server exposes /// the tags this server exposes
char m_szGameTags[k_cbMaxGameServerTags]; char m_szGameTags[k_cbMaxGameServerTags];
/// steamID of the game server - invalid if it's doesn't have one (old server, or not connected to Steam) /// steamID of the game server - invalid if it's doesn't have one (old server, or not connected to Steam)
CSteamID m_steamID; CSteamID m_steamID;
}; };
inline gameserveritem_t::gameserveritem_t() inline gameserveritem_t::gameserveritem_t()
{ {
m_szGameDir[0] = m_szMap[0] = m_szGameDescription[0] = m_szServerName[0] = 0; m_szGameDir[0] = m_szMap[0] = m_szGameDescription[0] = m_szServerName[0] = 0;
m_bHadSuccessfulResponse = m_bDoNotRefresh = m_bPassword = m_bSecure = false; m_bHadSuccessfulResponse = m_bDoNotRefresh = m_bPassword = m_bSecure = false;
m_nPing = m_nAppID = m_nPlayers = m_nMaxPlayers = m_nBotPlayers = m_ulTimeLastPlayed = m_nServerVersion = 0; m_nPing = m_nAppID = m_nPlayers = m_nMaxPlayers = m_nBotPlayers = m_ulTimeLastPlayed = m_nServerVersion = 0;
m_szGameTags[0] = 0; m_szGameTags[0] = 0;
} }
inline const char* gameserveritem_t::GetName() const inline const char* gameserveritem_t::GetName() const
{ {
// Use the IP address as the name if nothing is set yet. // Use the IP address as the name if nothing is set yet.
if ( m_szServerName[0] == 0 ) if (m_szServerName[0] == 0)
return m_NetAdr.GetConnectionAddressString(); return m_NetAdr.GetConnectionAddressString();
else else
return m_szServerName; return m_szServerName;
} }
inline void gameserveritem_t::SetName( const char *pName ) inline void gameserveritem_t::SetName(const char* pName)
{ {
strncpy( m_szServerName, pName, sizeof( m_szServerName ) ); strncpy(m_szServerName, pName, sizeof(m_szServerName));
m_szServerName[ sizeof( m_szServerName ) - 1 ] = '\0'; m_szServerName[sizeof(m_szServerName) - 1] = '\0';
} }
#endif // MATCHMAKINGTYPES_H #endif // MATCHMAKINGTYPES_H

View File

@ -21,32 +21,31 @@
#include "steam_api_common.h" #include "steam_api_common.h"
// All of the interfaces // All of the interfaces
#include "isteamclient.h" #include "isteamapplist.h"
#include "isteamuser.h"
#include "isteamfriends.h"
#include "isteamutils.h"
#include "isteammatchmaking.h"
#include "isteamuserstats.h"
#include "isteamapps.h" #include "isteamapps.h"
#include "isteamnetworking.h" #include "isteamclient.h"
#include "isteamremotestorage.h" #include "isteamcontroller.h"
#include "isteamscreenshots.h" #include "isteamfriends.h"
#include "isteamhtmlsurface.h"
#include "isteamhttp.h"
#include "isteaminput.h"
#include "isteaminventory.h"
#include "isteammatchmaking.h"
#include "isteammusic.h" #include "isteammusic.h"
#include "isteammusicremote.h" #include "isteammusicremote.h"
#include "isteamhttp.h" #include "isteamnetworking.h"
#include "isteamcontroller.h"
#include "isteamugc.h"
#include "isteamapplist.h"
#include "isteamhtmlsurface.h"
#include "isteaminventory.h"
#include "isteamvideo.h"
#include "isteamparentalsettings.h"
#include "isteaminput.h"
#include "isteamremoteplay.h"
#include "isteamnetworkingmessages.h" #include "isteamnetworkingmessages.h"
#include "isteamnetworkingsockets.h" #include "isteamnetworkingsockets.h"
#include "isteamnetworkingutils.h" #include "isteamnetworkingutils.h"
#include "isteamparentalsettings.h"
#include "isteamremoteplay.h"
#include "isteamremotestorage.h"
#include "isteamscreenshots.h"
#include "isteamugc.h"
#include "isteamuser.h"
#include "isteamuserstats.h"
#include "isteamutils.h"
#include "isteamvideo.h"
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
// Steam API setup & shutdown // Steam API setup & shutdown
@ -55,7 +54,6 @@
// //
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
// SteamAPI_Init must be called before using any other API functions. If it fails, an // SteamAPI_Init must be called before using any other API functions. If it fails, an
// error message will be output to the debugger (or stderr) with further information. // error message will be output to the debugger (or stderr) with further information.
S_API bool S_CALLTYPE SteamAPI_Init(); S_API bool S_CALLTYPE SteamAPI_Init();
@ -73,7 +71,7 @@ S_API void S_CALLTYPE SteamAPI_Shutdown();
// //
// NOTE: If you use the Steam DRM wrapper on your primary executable file, this check is unnecessary // NOTE: If you use the Steam DRM wrapper on your primary executable file, this check is unnecessary
// since the DRM wrapper will ensure that your application was launched properly through Steam. // since the DRM wrapper will ensure that your application was launched properly through Steam.
S_API bool S_CALLTYPE SteamAPI_RestartAppIfNecessary( uint32 unOwnAppID ); S_API bool S_CALLTYPE SteamAPI_RestartAppIfNecessary(uint32 unOwnAppID);
// Many Steam API functions allocate a small amount of thread-local memory for parameter storage. // Many Steam API functions allocate a small amount of thread-local memory for parameter storage.
// SteamAPI_ReleaseCurrentThreadMemory() will free API memory associated with the calling thread. // SteamAPI_ReleaseCurrentThreadMemory() will free API memory associated with the calling thread.
@ -81,10 +79,9 @@ S_API bool S_CALLTYPE SteamAPI_RestartAppIfNecessary( uint32 unOwnAppID );
// program never needs to explicitly call this function. // program never needs to explicitly call this function.
S_API void S_CALLTYPE SteamAPI_ReleaseCurrentThreadMemory(); S_API void S_CALLTYPE SteamAPI_ReleaseCurrentThreadMemory();
// crash dump recording functions // crash dump recording functions
S_API void S_CALLTYPE SteamAPI_WriteMiniDump( uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID ); S_API void S_CALLTYPE SteamAPI_WriteMiniDump(uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID);
S_API void S_CALLTYPE SteamAPI_SetMiniDumpComment( const char *pchMsg ); S_API void S_CALLTYPE SteamAPI_SetMiniDumpComment(const char* pchMsg);
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
// steamclient.dll private wrapper functions // steamclient.dll private wrapper functions
@ -97,13 +94,13 @@ S_API bool S_CALLTYPE SteamAPI_IsSteamRunning();
// returns the filename path of the current running Steam process, used if you need to load an explicit steam dll by name. // returns the filename path of the current running Steam process, used if you need to load an explicit steam dll by name.
// DEPRECATED - implementation is Windows only, and the path returned is a UTF-8 string which must be converted to UTF-16 for use with Win32 APIs // DEPRECATED - implementation is Windows only, and the path returned is a UTF-8 string which must be converted to UTF-16 for use with Win32 APIs
S_API const char *SteamAPI_GetSteamInstallPath(); S_API const char* SteamAPI_GetSteamInstallPath();
// sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks // sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks
// This is ignored if you are using the manual callback dispatch method // This is ignored if you are using the manual callback dispatch method
S_API void SteamAPI_SetTryCatchCallbacks( bool bTryCatchCallbacks ); S_API void SteamAPI_SetTryCatchCallbacks(bool bTryCatchCallbacks);
#if defined( VERSION_SAFE_STEAM_API_INTERFACES ) #if defined(VERSION_SAFE_STEAM_API_INTERFACES)
// exists only for backwards compat with code written against older SDKs // exists only for backwards compat with code written against older SDKs
S_API bool S_CALLTYPE SteamAPI_InitSafe(); S_API bool S_CALLTYPE SteamAPI_InitSafe();
#endif #endif
@ -115,8 +112,8 @@ S_API bool S_CALLTYPE SteamAPI_InitSafe();
// bFullMemoryDumps (Win32 only) -- writes out a uuid-full.dmp in the client/dumps folder // bFullMemoryDumps (Win32 only) -- writes out a uuid-full.dmp in the client/dumps folder
// pvContext-- can be NULL, will be the void * context passed into m_pfnPreMinidumpCallback // pvContext-- can be NULL, will be the void * context passed into m_pfnPreMinidumpCallback
// PFNPreMinidumpCallback m_pfnPreMinidumpCallback -- optional callback which occurs just before a .dmp file is written during a crash. Applications can hook this to allow adding additional information into the .dmp comment stream. // PFNPreMinidumpCallback m_pfnPreMinidumpCallback -- optional callback which occurs just before a .dmp file is written during a crash. Applications can hook this to allow adding additional information into the .dmp comment stream.
S_API void S_CALLTYPE SteamAPI_UseBreakpadCrashHandler( char const *pchVersion, char const *pchDate, char const *pchTime, bool bFullMemoryDumps, void *pvContext, PFNPreMinidumpCallback m_pfnPreMinidumpCallback ); S_API void S_CALLTYPE SteamAPI_UseBreakpadCrashHandler(char const* pchVersion, char const* pchDate, char const* pchTime, bool bFullMemoryDumps, void* pvContext, PFNPreMinidumpCallback m_pfnPreMinidumpCallback);
S_API void S_CALLTYPE SteamAPI_SetBreakpadAppID( uint32 unAppID ); S_API void S_CALLTYPE SteamAPI_SetBreakpadAppID(uint32 unAppID);
#endif #endif
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
@ -167,19 +164,19 @@ S_API void S_CALLTYPE SteamAPI_SetBreakpadAppID( uint32 unAppID );
S_API void S_CALLTYPE SteamAPI_ManualDispatch_Init(); S_API void S_CALLTYPE SteamAPI_ManualDispatch_Init();
/// Perform certain periodic actions that need to be performed. /// Perform certain periodic actions that need to be performed.
S_API void S_CALLTYPE SteamAPI_ManualDispatch_RunFrame( HSteamPipe hSteamPipe ); S_API void S_CALLTYPE SteamAPI_ManualDispatch_RunFrame(HSteamPipe hSteamPipe);
/// Fetch the next pending callback on the given pipe, if any. If a callback is available, true is returned /// Fetch the next pending callback on the given pipe, if any. If a callback is available, true is returned
/// and the structure is populated. In this case, you MUST call SteamAPI_ManualDispatch_FreeLastCallback /// and the structure is populated. In this case, you MUST call SteamAPI_ManualDispatch_FreeLastCallback
/// (after dispatching the callback) before calling SteamAPI_ManualDispatch_GetNextCallback again. /// (after dispatching the callback) before calling SteamAPI_ManualDispatch_GetNextCallback again.
S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetNextCallback( HSteamPipe hSteamPipe, CallbackMsg_t *pCallbackMsg ); S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetNextCallback(HSteamPipe hSteamPipe, CallbackMsg_t* pCallbackMsg);
/// You must call this after dispatching the callback, if SteamAPI_ManualDispatch_GetNextCallback returns true. /// You must call this after dispatching the callback, if SteamAPI_ManualDispatch_GetNextCallback returns true.
S_API void S_CALLTYPE SteamAPI_ManualDispatch_FreeLastCallback( HSteamPipe hSteamPipe ); S_API void S_CALLTYPE SteamAPI_ManualDispatch_FreeLastCallback(HSteamPipe hSteamPipe);
/// Return the call result for the specified call on the specified pipe. You really should /// Return the call result for the specified call on the specified pipe. You really should
/// only call this in a handler for SteamAPICallCompleted_t callback. /// only call this in a handler for SteamAPICallCompleted_t callback.
S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed ); S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetAPICallResult(HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed);
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
// //
@ -193,103 +190,103 @@ S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hStea
inline bool CSteamAPIContext::Init() inline bool CSteamAPIContext::Init()
{ {
m_pSteamClient = ::SteamClient(); m_pSteamClient = ::SteamClient();
if ( !m_pSteamClient ) if (!m_pSteamClient)
return false; return false;
m_pSteamUser = ::SteamUser(); m_pSteamUser = ::SteamUser();
if ( !m_pSteamUser ) if (!m_pSteamUser)
return false; return false;
m_pSteamFriends = ::SteamFriends(); m_pSteamFriends = ::SteamFriends();
if ( !m_pSteamFriends ) if (!m_pSteamFriends)
return false; return false;
m_pSteamUtils = ::SteamUtils(); m_pSteamUtils = ::SteamUtils();
if ( !m_pSteamUtils ) if (!m_pSteamUtils)
return false; return false;
m_pSteamMatchmaking = ::SteamMatchmaking(); m_pSteamMatchmaking = ::SteamMatchmaking();
if ( !m_pSteamMatchmaking ) if (!m_pSteamMatchmaking)
return false; return false;
m_pSteamGameSearch = ::SteamGameSearch(); m_pSteamGameSearch = ::SteamGameSearch();
if ( !m_pSteamGameSearch ) if (!m_pSteamGameSearch)
return false; return false;
#if !defined( IOSALL) // Not yet supported on iOS. #if !defined(IOSALL) // Not yet supported on iOS.
m_pSteamMatchmakingServers = ::SteamMatchmakingServers(); m_pSteamMatchmakingServers = ::SteamMatchmakingServers();
if ( !m_pSteamMatchmakingServers ) if (!m_pSteamMatchmakingServers)
return false; return false;
#endif #endif
m_pSteamUserStats = ::SteamUserStats(); m_pSteamUserStats = ::SteamUserStats();
if ( !m_pSteamUserStats ) if (!m_pSteamUserStats)
return false; return false;
m_pSteamApps = ::SteamApps(); m_pSteamApps = ::SteamApps();
if ( !m_pSteamApps ) if (!m_pSteamApps)
return false; return false;
m_pSteamNetworking = ::SteamNetworking(); m_pSteamNetworking = ::SteamNetworking();
if ( !m_pSteamNetworking ) if (!m_pSteamNetworking)
return false; return false;
m_pSteamRemoteStorage = ::SteamRemoteStorage(); m_pSteamRemoteStorage = ::SteamRemoteStorage();
if ( !m_pSteamRemoteStorage ) if (!m_pSteamRemoteStorage)
return false; return false;
m_pSteamScreenshots = ::SteamScreenshots(); m_pSteamScreenshots = ::SteamScreenshots();
if ( !m_pSteamScreenshots ) if (!m_pSteamScreenshots)
return false; return false;
m_pSteamHTTP = ::SteamHTTP(); m_pSteamHTTP = ::SteamHTTP();
if ( !m_pSteamHTTP ) if (!m_pSteamHTTP)
return false; return false;
m_pController = ::SteamController(); m_pController = ::SteamController();
if ( !m_pController ) if (!m_pController)
return false; return false;
m_pSteamUGC = ::SteamUGC(); m_pSteamUGC = ::SteamUGC();
if ( !m_pSteamUGC ) if (!m_pSteamUGC)
return false; return false;
m_pSteamAppList = ::SteamAppList(); m_pSteamAppList = ::SteamAppList();
if ( !m_pSteamAppList ) if (!m_pSteamAppList)
return false; return false;
m_pSteamMusic = ::SteamMusic(); m_pSteamMusic = ::SteamMusic();
if ( !m_pSteamMusic ) if (!m_pSteamMusic)
return false; return false;
m_pSteamMusicRemote = ::SteamMusicRemote(); m_pSteamMusicRemote = ::SteamMusicRemote();
if ( !m_pSteamMusicRemote ) if (!m_pSteamMusicRemote)
return false; return false;
#if !defined( ANDROID ) && !defined( IOSALL) // Not yet supported on Android or ios. #if !defined(ANDROID) && !defined(IOSALL) // Not yet supported on Android or ios.
m_pSteamHTMLSurface = ::SteamHTMLSurface(); m_pSteamHTMLSurface = ::SteamHTMLSurface();
if ( !m_pSteamHTMLSurface ) if (!m_pSteamHTMLSurface)
return false; return false;
#endif #endif
m_pSteamInventory = ::SteamInventory(); m_pSteamInventory = ::SteamInventory();
if ( !m_pSteamInventory ) if (!m_pSteamInventory)
return false; return false;
m_pSteamVideo = ::SteamVideo(); m_pSteamVideo = ::SteamVideo();
if ( !m_pSteamVideo ) if (!m_pSteamVideo)
return false; return false;
m_pSteamParentalSettings = ::SteamParentalSettings(); m_pSteamParentalSettings = ::SteamParentalSettings();
if ( !m_pSteamParentalSettings ) if (!m_pSteamParentalSettings)
return false; return false;
m_pSteamInput = ::SteamInput(); m_pSteamInput = ::SteamInput();
if ( !m_pSteamInput ) if (!m_pSteamInput)
return false; return false;
return true; return true;
} }
#endif #endif

View File

@ -13,38 +13,40 @@
#pragma once #pragma once
#endif #endif
#include "steamtypes.h"
#include "steamclientpublic.h" #include "steamclientpublic.h"
#include "steamtypes.h"
// S_API defines the linkage and calling conventions for steam_api.dll exports // S_API defines the linkage and calling conventions for steam_api.dll exports
#if defined( _WIN32 ) && !defined( _X360 ) #if defined(_WIN32) && !defined(_X360)
#if defined( STEAM_API_EXPORTS ) #if defined(STEAM_API_EXPORTS)
#define S_API extern "C" __declspec( dllexport ) #define S_API extern "C" __declspec(dllexport)
#elif defined( STEAM_API_NODLL ) #elif defined(STEAM_API_NODLL)
#define S_API extern "C" #define S_API extern "C"
#else #else
#define S_API extern "C" __declspec( dllimport ) #define S_API extern "C" __declspec(dllimport)
#endif // STEAM_API_EXPORTS #endif // STEAM_API_EXPORTS
#elif defined( GNUC ) #elif defined(GNUC)
#if defined( STEAM_API_EXPORTS ) #if defined(STEAM_API_EXPORTS)
#define S_API extern "C" __attribute__ ((visibility("default"))) #define S_API extern "C" __attribute__((visibility("default")))
#else #else
#define S_API extern "C" #define S_API extern "C"
#endif // STEAM_API_EXPORTS #endif // STEAM_API_EXPORTS
#else // !WIN32 #else // !WIN32
#if defined( STEAM_API_EXPORTS ) #if defined(STEAM_API_EXPORTS)
#define S_API extern "C" #define S_API extern "C"
#else #else
#define S_API extern "C" #define S_API extern "C"
#endif // STEAM_API_EXPORTS #endif // STEAM_API_EXPORTS
#endif #endif
#if ( defined(STEAM_API_EXPORTS) || defined(STEAM_API_NODLL) ) && !defined(API_GEN) #if (defined(STEAM_API_EXPORTS) || defined(STEAM_API_NODLL)) && !defined(API_GEN)
#define STEAM_PRIVATE_API( ... ) __VA_ARGS__ #define STEAM_PRIVATE_API(...) __VA_ARGS__
#elif defined(STEAM_API_EXPORTS) && defined(API_GEN) #elif defined(STEAM_API_EXPORTS) && defined(API_GEN)
#define STEAM_PRIVATE_API( ... ) #define STEAM_PRIVATE_API(...)
#else #else
#define STEAM_PRIVATE_API( ... ) protected: __VA_ARGS__ public: #define STEAM_PRIVATE_API(...) \
protected: \
__VA_ARGS__ public:
#endif #endif
// handle to a communication pipe to the Steam client // handle to a communication pipe to the Steam client
@ -52,13 +54,13 @@ typedef int32 HSteamPipe;
// handle to single instance of a steam user // handle to single instance of a steam user
typedef int32 HSteamUser; typedef int32 HSteamUser;
// function prototype // function prototype
#if defined( POSIX ) #if defined(POSIX)
#define __cdecl #define __cdecl
#endif #endif
extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *); extern "C" typedef void(__cdecl* SteamAPIWarningMessageHook_t)(int, const char*);
extern "C" typedef uint32 ( *SteamAPI_CheckCallbackRegistered_t )( int iCallbackNum ); extern "C" typedef uint32 (*SteamAPI_CheckCallbackRegistered_t)(int iCallbackNum);
#if defined( __SNC__ ) #if defined(__SNC__)
#pragma diag_suppress=1700 // warning 1700: class "%s" has virtual functions but non-virtual destructor #pragma diag_suppress = 1700 // warning 1700: class "%s" has virtual functions but non-virtual destructor
#endif #endif
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
@ -98,13 +100,14 @@ S_API void S_CALLTYPE SteamAPI_RunCallbacks();
// registers the callback on object creation and unregisters on destruction. // registers the callback on object creation and unregisters on destruction.
// The optional fourth 'var' param exists only for backwards-compatibility // The optional fourth 'var' param exists only for backwards-compatibility
// and can be ignored. // and can be ignored.
#define STEAM_CALLBACK( thisclass, func, .../*callback_type, [deprecated] var*/ ) \ #define STEAM_CALLBACK(thisclass, func, ... /*callback_type, [deprecated] var*/) \
_STEAM_CALLBACK_SELECT( ( __VA_ARGS__, 4, 3 ), ( /**/, thisclass, func, __VA_ARGS__ ) ) _STEAM_CALLBACK_SELECT((__VA_ARGS__, 4, 3), (/**/, thisclass, func, __VA_ARGS__))
// Declares a callback function and a named CCallbackManual variable which // Declares a callback function and a named CCallbackManual variable which
// has Register and Unregister functions instead of automatic registration. // has Register and Unregister functions instead of automatic registration.
#define STEAM_CALLBACK_MANUAL( thisclass, func, callback_type, var ) \ #define STEAM_CALLBACK_MANUAL(thisclass, func, callback_type, var) \
CCallbackManual< thisclass, callback_type > var; void func( callback_type *pParam ) CCallbackManual<thisclass, callback_type> var; \
void func(callback_type* pParam)
// Dispatch callbacks relevant to the gameserver client and interfaces. // Dispatch callbacks relevant to the gameserver client and interfaces.
// To register for these, you need to use STEAM_GAMESERVER_CALLBACK. // To register for these, you need to use STEAM_GAMESERVER_CALLBACK.
@ -113,120 +116,125 @@ S_API void S_CALLTYPE SteamGameServer_RunCallbacks();
// Same as STEAM_CALLBACK, but for callbacks on the gameserver interface. // Same as STEAM_CALLBACK, but for callbacks on the gameserver interface.
// These will be dispatched during SteamGameServer_RunCallbacks // These will be dispatched during SteamGameServer_RunCallbacks
#define STEAM_GAMESERVER_CALLBACK( thisclass, func, /*callback_type, [deprecated] var*/... ) \ #define STEAM_GAMESERVER_CALLBACK(thisclass, func, /*callback_type, [deprecated] var*/...) \
_STEAM_CALLBACK_SELECT( ( __VA_ARGS__, GS, 3 ), ( this->SetGameserverFlag();, thisclass, func, __VA_ARGS__ ) ) _STEAM_CALLBACK_SELECT((__VA_ARGS__, GS, 3), (this->SetGameserverFlag();, thisclass, func, __VA_ARGS__))
#define STEAM_GAMESERVER_CALLBACK_MANUAL( thisclass, func, callback_type, var ) \ #define STEAM_GAMESERVER_CALLBACK_MANUAL(thisclass, func, callback_type, var) \
CCallbackManual< thisclass, callback_type, true > var; void func( callback_type *pParam ) CCallbackManual<thisclass, callback_type, true> var; \
void func(callback_type* pParam)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: base for callbacks and call results - internal implementation detail // Purpose: base for callbacks and call results - internal implementation detail
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class CCallbackBase class CCallbackBase {
{
public: public:
CCallbackBase() { m_nCallbackFlags = 0; m_iCallback = 0; } CCallbackBase()
// don't add a virtual destructor because we export this binary interface across dll's {
virtual void Run( void *pvParam ) = 0; m_nCallbackFlags = 0;
virtual void Run( void *pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall ) = 0; m_iCallback = 0;
int GetICallback() { return m_iCallback; } }
virtual int GetCallbackSizeBytes() = 0; // don't add a virtual destructor because we export this binary interface across dll's
virtual void Run(void* pvParam) = 0;
virtual void Run(void* pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall) = 0;
int GetICallback() { return m_iCallback; }
virtual int GetCallbackSizeBytes() = 0;
protected: protected:
enum { k_ECallbackFlagsRegistered = 0x01, k_ECallbackFlagsGameServer = 0x02 }; enum { k_ECallbackFlagsRegistered = 0x01,
uint8 m_nCallbackFlags; k_ECallbackFlagsGameServer = 0x02 };
int m_iCallback; uint8 m_nCallbackFlags;
friend class CCallbackMgr; int m_iCallback;
friend class CCallbackMgr;
private: private:
CCallbackBase( const CCallbackBase& ); CCallbackBase(const CCallbackBase&);
CCallbackBase& operator=( const CCallbackBase& ); CCallbackBase& operator=(const CCallbackBase&);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: templated base for callbacks - internal implementation detail // Purpose: templated base for callbacks - internal implementation detail
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< int sizeof_P > template <int sizeof_P>
class CCallbackImpl : protected CCallbackBase class CCallbackImpl : protected CCallbackBase {
{
public: public:
virtual ~CCallbackImpl() { if ( m_nCallbackFlags & k_ECallbackFlagsRegistered ) SteamAPI_UnregisterCallback( this ); } virtual ~CCallbackImpl()
void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; } {
if (m_nCallbackFlags & k_ECallbackFlagsRegistered)
SteamAPI_UnregisterCallback(this);
}
void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; }
protected: protected:
friend class CCallbackMgr; friend class CCallbackMgr;
virtual void Run( void *pvParam ) = 0; virtual void Run(void* pvParam) = 0;
virtual void Run( void *pvParam, bool /*bIOFailure*/, SteamAPICall_t /*hSteamAPICall*/ ) { Run( pvParam ); } virtual void Run(void* pvParam, bool /*bIOFailure*/, SteamAPICall_t /*hSteamAPICall*/) { Run(pvParam); }
virtual int GetCallbackSizeBytes() { return sizeof_P; } virtual int GetCallbackSizeBytes() { return sizeof_P; }
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: maps a steam async call result to a class member function // Purpose: maps a steam async call result to a class member function
// template params: T = local class, P = parameter struct // template params: T = local class, P = parameter struct
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T, class P > template <class T, class P>
class CCallResult : private CCallbackBase class CCallResult : private CCallbackBase {
{
public: public:
typedef void (T::*func_t)( P*, bool ); typedef void (T::*func_t)(P*, bool);
CCallResult(); CCallResult();
~CCallResult(); ~CCallResult();
void Set( SteamAPICall_t hAPICall, T *p, func_t func ); void Set(SteamAPICall_t hAPICall, T* p, func_t func);
bool IsActive() const; bool IsActive() const;
void Cancel(); void Cancel();
void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; }
void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; }
private: private:
virtual void Run( void *pvParam ); virtual void Run(void* pvParam);
virtual void Run( void *pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall ); virtual void Run(void* pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall);
virtual int GetCallbackSizeBytes() { return sizeof( P ); } virtual int GetCallbackSizeBytes() { return sizeof(P); }
SteamAPICall_t m_hAPICall; SteamAPICall_t m_hAPICall;
T *m_pObj; T* m_pObj;
func_t m_Func; func_t m_Func;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: maps a steam callback to a class member function // Purpose: maps a steam callback to a class member function
// template params: T = local class, P = parameter struct, // template params: T = local class, P = parameter struct,
// bGameserver = listen for gameserver callbacks instead of client callbacks // bGameserver = listen for gameserver callbacks instead of client callbacks
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T, class P, bool bGameserver = false > template <class T, class P, bool bGameserver = false>
class CCallback : public CCallbackImpl< sizeof( P ) > class CCallback : public CCallbackImpl<sizeof(P)> {
{
public: public:
typedef void (T::*func_t)(P*); typedef void (T::*func_t)(P*);
// NOTE: If you can't provide the correct parameters at construction time, you should // NOTE: If you can't provide the correct parameters at construction time, you should
// use the CCallbackManual callback object (STEAM_CALLBACK_MANUAL macro) instead. // use the CCallbackManual callback object (STEAM_CALLBACK_MANUAL macro) instead.
CCallback( T *pObj, func_t func ); CCallback(T* pObj, func_t func);
void Register( T *pObj, func_t func ); void Register(T* pObj, func_t func);
void Unregister(); void Unregister();
protected: protected:
virtual void Run( void *pvParam ); virtual void Run(void* pvParam);
T *m_pObj;
func_t m_Func;
};
T* m_pObj;
func_t m_Func;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: subclass of CCallback which allows default-construction in // Purpose: subclass of CCallback which allows default-construction in
// an unregistered state; you must call Register manually // an unregistered state; you must call Register manually
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T, class P, bool bGameServer = false > template <class T, class P, bool bGameServer = false>
class CCallbackManual : public CCallback< T, P, bGameServer > class CCallbackManual : public CCallback<T, P, bGameServer> {
{
public: public:
CCallbackManual() : CCallback< T, P, bGameServer >( nullptr, nullptr ) {} CCallbackManual()
: CCallback<T, P, bGameServer>(nullptr, nullptr)
{
}
// Inherits public Register and Unregister functions from base class // Inherits public Register and Unregister functions from base class
}; };
// Internal implementation details for all of the above // Internal implementation details for all of the above

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
// //
// You should be able to figure out how to use the SDK by reading // You should be able to figure out how to use the SDK by reading
// steam_api_common.h, and should not need to understand anything in here. // steam_api_common.h, and should not need to understand anything in here.
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifdef STEAM_CALLBACK_BEGIN #ifdef STEAM_CALLBACK_BEGIN
@ -18,10 +18,10 @@ S_API HSteamPipe S_CALLTYPE SteamAPI_GetHSteamPipe();
S_API HSteamUser S_CALLTYPE SteamAPI_GetHSteamUser(); S_API HSteamUser S_CALLTYPE SteamAPI_GetHSteamUser();
S_API HSteamPipe S_CALLTYPE SteamGameServer_GetHSteamPipe(); S_API HSteamPipe S_CALLTYPE SteamGameServer_GetHSteamPipe();
S_API HSteamUser S_CALLTYPE SteamGameServer_GetHSteamUser(); S_API HSteamUser S_CALLTYPE SteamGameServer_GetHSteamUser();
S_API void *S_CALLTYPE SteamInternal_ContextInit( void *pContextInitData ); S_API void* S_CALLTYPE SteamInternal_ContextInit(void* pContextInitData);
S_API void *S_CALLTYPE SteamInternal_CreateInterface( const char *ver ); S_API void* S_CALLTYPE SteamInternal_CreateInterface(const char* ver);
S_API void *S_CALLTYPE SteamInternal_FindOrCreateUserInterface( HSteamUser hSteamUser, const char *pszVersion ); S_API void* S_CALLTYPE SteamInternal_FindOrCreateUserInterface(HSteamUser hSteamUser, const char* pszVersion);
S_API void *S_CALLTYPE SteamInternal_FindOrCreateGameServerInterface( HSteamUser hSteamUser, const char *pszVersion ); S_API void* S_CALLTYPE SteamInternal_FindOrCreateGameServerInterface(HSteamUser hSteamUser, const char* pszVersion);
// Macro used to define a type-safe accessor that will always return the version // Macro used to define a type-safe accessor that will always return the version
// of the interface of the *header file* you are compiling with! We also bounce // of the interface of the *header file* you are compiling with! We also bounce
@ -30,187 +30,196 @@ S_API void *S_CALLTYPE SteamInternal_FindOrCreateGameServerInterface( HSteamUser
// SteamInternal_ContextInit takes a base pointer for the equivalent of // SteamInternal_ContextInit takes a base pointer for the equivalent of
// struct { void (*pFn)(void* pCtx); uintptr_t counter; void *ptr; } // struct { void (*pFn)(void* pCtx); uintptr_t counter; void *ptr; }
// Do not change layout or add non-pointer aligned data! // Do not change layout or add non-pointer aligned data!
#define STEAM_DEFINE_INTERFACE_ACCESSOR( type, name, expr, kind, version ) \ #define STEAM_DEFINE_INTERFACE_ACCESSOR(type, name, expr, kind, version) \
inline void S_CALLTYPE SteamInternal_Init_ ## name( type *p ) { *p = (type)( expr ); } \ inline void S_CALLTYPE SteamInternal_Init_##name(type* p) { *p = (type)(expr); } \
STEAM_CLANG_ATTR( "interface_accessor_kind:" kind ";interface_accessor_version:" version ";" ) \ STEAM_CLANG_ATTR("interface_accessor_kind:" kind ";interface_accessor_version:" version ";") \
inline type name() { \ inline type name() \
static void* s_CallbackCounterAndContext[ 3 ] = { (void*)&SteamInternal_Init_ ## name, 0, 0 }; \ { \
return *(type*)SteamInternal_ContextInit( s_CallbackCounterAndContext ); \ static void* s_CallbackCounterAndContext[3] = { (void*)&SteamInternal_Init_##name, 0, 0 }; \
} return *(type*)SteamInternal_ContextInit(s_CallbackCounterAndContext); \
}
#define STEAM_DEFINE_USER_INTERFACE_ACCESSOR( type, name, version ) \ #define STEAM_DEFINE_USER_INTERFACE_ACCESSOR(type, name, version) \
STEAM_DEFINE_INTERFACE_ACCESSOR( type, name, SteamInternal_FindOrCreateUserInterface( SteamAPI_GetHSteamUser(), version ), "user", version ) STEAM_DEFINE_INTERFACE_ACCESSOR(type, name, SteamInternal_FindOrCreateUserInterface(SteamAPI_GetHSteamUser(), version), "user", version)
#define STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR( type, name, version ) \ #define STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(type, name, version) \
STEAM_DEFINE_INTERFACE_ACCESSOR( type, name, SteamInternal_FindOrCreateGameServerInterface( SteamGameServer_GetHSteamUser(), version ), "gameserver", version ) STEAM_DEFINE_INTERFACE_ACCESSOR(type, name, SteamInternal_FindOrCreateGameServerInterface(SteamGameServer_GetHSteamUser(), version), "gameserver", version)
// //
// Internal stuff used for the standard, higher-level callback mechanism // Internal stuff used for the standard, higher-level callback mechanism
// //
// Internal functions used by the utility CCallback objects to receive callbacks // Internal functions used by the utility CCallback objects to receive callbacks
S_API void S_CALLTYPE SteamAPI_RegisterCallback( class CCallbackBase *pCallback, int iCallback ); S_API void S_CALLTYPE SteamAPI_RegisterCallback(class CCallbackBase* pCallback, int iCallback);
S_API void S_CALLTYPE SteamAPI_UnregisterCallback( class CCallbackBase *pCallback ); S_API void S_CALLTYPE SteamAPI_UnregisterCallback(class CCallbackBase* pCallback);
// Internal functions used by the utility CCallResult objects to receive async call results // Internal functions used by the utility CCallResult objects to receive async call results
S_API void S_CALLTYPE SteamAPI_RegisterCallResult( class CCallbackBase *pCallback, SteamAPICall_t hAPICall ); S_API void S_CALLTYPE SteamAPI_RegisterCallResult(class CCallbackBase* pCallback, SteamAPICall_t hAPICall);
S_API void S_CALLTYPE SteamAPI_UnregisterCallResult( class CCallbackBase *pCallback, SteamAPICall_t hAPICall ); S_API void S_CALLTYPE SteamAPI_UnregisterCallResult(class CCallbackBase* pCallback, SteamAPICall_t hAPICall);
// disable this warning; this pattern need for steam callback registration // disable this warning; this pattern need for steam callback registration
#ifdef _MSVC_VER #ifdef _MSVC_VER
#pragma warning( push ) #pragma warning(push)
#pragma warning( disable: 4355 ) // 'this' : used in base member initializer list #pragma warning(disable : 4355) // 'this' : used in base member initializer list
#endif #endif
#define _STEAM_CALLBACK_AUTO_HOOK( thisclass, func, param ) #define _STEAM_CALLBACK_AUTO_HOOK(thisclass, func, param)
#define _STEAM_CALLBACK_HELPER( _1, _2, SELECTED, ... ) _STEAM_CALLBACK_##SELECTED #define _STEAM_CALLBACK_HELPER(_1, _2, SELECTED, ...) _STEAM_CALLBACK_##SELECTED
#define _STEAM_CALLBACK_SELECT( X, Y ) _STEAM_CALLBACK_HELPER X Y #define _STEAM_CALLBACK_SELECT(X, Y) _STEAM_CALLBACK_HELPER X Y
#define _STEAM_CALLBACK_3( extra_code, thisclass, func, param ) \ #define _STEAM_CALLBACK_3(extra_code, thisclass, func, param) \
struct CCallbackInternal_ ## func : private CCallbackImpl< sizeof( param ) > { \ struct CCallbackInternal_##func : private CCallbackImpl<sizeof(param)> { \
CCallbackInternal_ ## func () { extra_code SteamAPI_RegisterCallback( this, param::k_iCallback ); } \ CCallbackInternal_##func() { extra_code SteamAPI_RegisterCallback(this, param::k_iCallback); } \
CCallbackInternal_ ## func ( const CCallbackInternal_ ## func & ) { extra_code SteamAPI_RegisterCallback( this, param::k_iCallback ); } \ CCallbackInternal_##func(const CCallbackInternal_##func&) { extra_code SteamAPI_RegisterCallback(this, param::k_iCallback); } \
CCallbackInternal_ ## func & operator=( const CCallbackInternal_ ## func & ) { return *this; } \ CCallbackInternal_##func& operator=(const CCallbackInternal_##func&) { return *this; } \
private: virtual void Run( void *pvParam ) { _STEAM_CALLBACK_AUTO_HOOK( thisclass, func, param ) \ \
thisclass *pOuter = reinterpret_cast<thisclass*>( reinterpret_cast<char*>(this) - offsetof( thisclass, m_steamcallback_ ## func ) ); \ private: \
pOuter->func( reinterpret_cast<param*>( pvParam ) ); \ virtual void Run(void* pvParam) \
} \ { \
} m_steamcallback_ ## func ; void func( param *pParam ) _STEAM_CALLBACK_AUTO_HOOK(thisclass, func, param) \
#define _STEAM_CALLBACK_4( _, thisclass, func, param, var ) \ thisclass* pOuter = reinterpret_cast<thisclass*>(reinterpret_cast<char*>(this) - offsetof(thisclass, m_steamcallback_##func)); \
CCallback< thisclass, param > var; void func( param *pParam ) pOuter->func(reinterpret_cast<param*>(pvParam)); \
#define _STEAM_CALLBACK_GS( _, thisclass, func, param, var ) \ } \
CCallback< thisclass, param, true > var; void func( param *pParam ) } m_steamcallback_##func; \
void func(param* pParam)
#define _STEAM_CALLBACK_4(_, thisclass, func, param, var) \
CCallback<thisclass, param> var; \
void func(param* pParam)
#define _STEAM_CALLBACK_GS(_, thisclass, func, param, var) \
CCallback<thisclass, param, true> var; \
void func(param* pParam)
#ifndef API_GEN #ifndef API_GEN
template< class T, class P > template <class T, class P>
inline CCallResult<T, P>::CCallResult() inline CCallResult<T, P>::CCallResult()
{ {
m_hAPICall = k_uAPICallInvalid; m_hAPICall = k_uAPICallInvalid;
m_pObj = nullptr; m_pObj = nullptr;
m_Func = nullptr; m_Func = nullptr;
m_iCallback = P::k_iCallback; m_iCallback = P::k_iCallback;
} }
template< class T, class P > template <class T, class P>
inline void CCallResult<T, P>::Set( SteamAPICall_t hAPICall, T *p, func_t func ) inline void CCallResult<T, P>::Set(SteamAPICall_t hAPICall, T* p, func_t func)
{ {
if ( m_hAPICall ) if (m_hAPICall)
SteamAPI_UnregisterCallResult( this, m_hAPICall ); SteamAPI_UnregisterCallResult(this, m_hAPICall);
m_hAPICall = hAPICall; m_hAPICall = hAPICall;
m_pObj = p; m_pObj = p;
m_Func = func; m_Func = func;
if ( hAPICall ) if (hAPICall)
SteamAPI_RegisterCallResult( this, hAPICall ); SteamAPI_RegisterCallResult(this, hAPICall);
} }
template< class T, class P > template <class T, class P>
inline bool CCallResult<T, P>::IsActive() const inline bool CCallResult<T, P>::IsActive() const
{ {
return (m_hAPICall != k_uAPICallInvalid); return (m_hAPICall != k_uAPICallInvalid);
} }
template< class T, class P > template <class T, class P>
inline void CCallResult<T, P>::Cancel() inline void CCallResult<T, P>::Cancel()
{ {
if ( m_hAPICall != k_uAPICallInvalid ) if (m_hAPICall != k_uAPICallInvalid) {
{ SteamAPI_UnregisterCallResult(this, m_hAPICall);
SteamAPI_UnregisterCallResult( this, m_hAPICall ); m_hAPICall = k_uAPICallInvalid;
m_hAPICall = k_uAPICallInvalid; }
}
} }
template< class T, class P > template <class T, class P>
inline CCallResult<T, P>::~CCallResult() inline CCallResult<T, P>::~CCallResult()
{ {
Cancel(); Cancel();
} }
template< class T, class P > template <class T, class P>
inline void CCallResult<T, P>::Run( void *pvParam ) inline void CCallResult<T, P>::Run(void* pvParam)
{ {
m_hAPICall = k_uAPICallInvalid; // caller unregisters for us m_hAPICall = k_uAPICallInvalid; // caller unregisters for us
(m_pObj->*m_Func)((P *)pvParam, false); (m_pObj->*m_Func)((P*)pvParam, false);
} }
template< class T, class P > template <class T, class P>
inline void CCallResult<T, P>::Run( void *pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall ) inline void CCallResult<T, P>::Run(void* pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall)
{ {
if ( hSteamAPICall == m_hAPICall ) if (hSteamAPICall == m_hAPICall) {
{ m_hAPICall = k_uAPICallInvalid; // caller unregisters for us
m_hAPICall = k_uAPICallInvalid; // caller unregisters for us (m_pObj->*m_Func)((P*)pvParam, bIOFailure);
(m_pObj->*m_Func)((P *)pvParam, bIOFailure); }
}
} }
template< class T, class P, bool bGameserver > template <class T, class P, bool bGameserver>
inline CCallback< T, P, bGameserver >::CCallback( T *pObj, func_t func ) inline CCallback<T, P, bGameserver>::CCallback(T* pObj, func_t func)
: m_pObj( nullptr ), m_Func( nullptr ) : m_pObj(nullptr)
, m_Func(nullptr)
{ {
if ( bGameserver ) if (bGameserver) {
{ this->SetGameserverFlag();
this->SetGameserverFlag(); }
} Register(pObj, func);
Register( pObj, func );
} }
template< class T, class P, bool bGameserver > template <class T, class P, bool bGameserver>
inline void CCallback< T, P, bGameserver >::Register( T *pObj, func_t func ) inline void CCallback<T, P, bGameserver>::Register(T* pObj, func_t func)
{ {
if ( !pObj || !func ) if (!pObj || !func)
return; return;
if ( this->m_nCallbackFlags & CCallbackBase::k_ECallbackFlagsRegistered ) if (this->m_nCallbackFlags & CCallbackBase::k_ECallbackFlagsRegistered)
Unregister(); Unregister();
m_pObj = pObj; m_pObj = pObj;
m_Func = func; m_Func = func;
// SteamAPI_RegisterCallback sets k_ECallbackFlagsRegistered // SteamAPI_RegisterCallback sets k_ECallbackFlagsRegistered
SteamAPI_RegisterCallback( this, P::k_iCallback ); SteamAPI_RegisterCallback(this, P::k_iCallback);
} }
template< class T, class P, bool bGameserver > template <class T, class P, bool bGameserver>
inline void CCallback< T, P, bGameserver >::Unregister() inline void CCallback<T, P, bGameserver>::Unregister()
{ {
// SteamAPI_UnregisterCallback removes k_ECallbackFlagsRegistered // SteamAPI_UnregisterCallback removes k_ECallbackFlagsRegistered
SteamAPI_UnregisterCallback( this ); SteamAPI_UnregisterCallback(this);
} }
template< class T, class P, bool bGameserver > template <class T, class P, bool bGameserver>
inline void CCallback< T, P, bGameserver >::Run( void *pvParam ) inline void CCallback<T, P, bGameserver>::Run(void* pvParam)
{ {
(m_pObj->*m_Func)((P *)pvParam); (m_pObj->*m_Func)((P*)pvParam);
} }
#endif // #ifndef API_GEN #endif // #ifndef API_GEN
// structure that contains client callback data // structure that contains client callback data
// see callbacks documentation for more details // see callbacks documentation for more details
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx #error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
#endif #endif
/// Internal structure used in manual callback dispatch /// Internal structure used in manual callback dispatch
struct CallbackMsg_t struct CallbackMsg_t {
{ HSteamUser m_hSteamUser; // Specific user to whom this callback applies.
HSteamUser m_hSteamUser; // Specific user to whom this callback applies. int m_iCallback; // Callback identifier. (Corresponds to the k_iCallback enum in the callback structure.)
int m_iCallback; // Callback identifier. (Corresponds to the k_iCallback enum in the callback structure.) uint8* m_pubParam; // Points to the callback structure
uint8 *m_pubParam; // Points to the callback structure int m_cubParam; // Size of the data pointed to by m_pubParam
int m_cubParam; // Size of the data pointed to by m_pubParam
}; };
#pragma pack( pop ) #pragma pack(pop)
// Macros to define steam callback structures. Used internally for debugging // Macros to define steam callback structures. Used internally for debugging
#ifdef STEAM_CALLBACK_INSPECTION_ENABLED #ifdef STEAM_CALLBACK_INSPECTION_ENABLED
#include "../../clientdll/steam_api_callback_inspection.h" #include "../../clientdll/steam_api_callback_inspection.h"
#else #else
#define STEAM_CALLBACK_BEGIN( callbackname, callbackid ) struct callbackname { enum { k_iCallback = callbackid }; #define STEAM_CALLBACK_BEGIN(callbackname, callbackid) \
#define STEAM_CALLBACK_MEMBER( varidx, vartype, varname ) vartype varname ; struct callbackname { \
#define STEAM_CALLBACK_MEMBER_ARRAY( varidx, vartype, varname, varcount ) vartype varname [ varcount ]; enum { k_iCallback = callbackid };
#define STEAM_CALLBACK_END(nArgs) }; #define STEAM_CALLBACK_MEMBER(varidx, vartype, varname) vartype varname;
#define STEAM_CALLBACK_MEMBER_ARRAY(varidx, vartype, varname, varcount) vartype varname[varcount];
#define STEAM_CALLBACK_END(nArgs) \
} \
;
#endif #endif
// Forward declare all of the Steam interfaces. (Do we really need to do this?) // Forward declare all of the Steam interfaces. (Do we really need to do this?)
@ -293,8 +302,8 @@ enum { k_iSteamAppListCallbacks = 3900 };
enum { k_iSteamMusicCallbacks = 4000 }; enum { k_iSteamMusicCallbacks = 4000 };
enum { k_iSteamMusicRemoteCallbacks = 4100 }; enum { k_iSteamMusicRemoteCallbacks = 4100 };
enum { k_iClientVRCallbacks = 4200 }; enum { k_iClientVRCallbacks = 4200 };
enum { k_iClientGameNotificationCallbacks = 4300 }; enum { k_iClientGameNotificationCallbacks = 4300 };
enum { k_iSteamGameNotificationCallbacks = 4400 }; enum { k_iSteamGameNotificationCallbacks = 4400 };
enum { k_iSteamHTMLSurfaceCallbacks = 4500 }; enum { k_iSteamHTMLSurfaceCallbacks = 4500 };
enum { k_iClientVideoCallbacks = 4600 }; enum { k_iClientVideoCallbacks = 4600 };
enum { k_iClientInventoryCallbacks = 4700 }; enum { k_iClientInventoryCallbacks = 4700 };
@ -312,7 +321,7 @@ enum { k_iClientCompatCallbacks = 5800 };
enum { k_iSteamChatCallbacks = 5900 }; enum { k_iSteamChatCallbacks = 5900 };
#ifdef _MSVC_VER #ifdef _MSVC_VER
#pragma warning( pop ) #pragma warning(pop)
#endif #endif
// CSteamAPIContext encapsulates the Steamworks API global accessors into // CSteamAPIContext encapsulates the Steamworks API global accessors into
@ -321,88 +330,85 @@ enum { k_iSteamChatCallbacks = 5900 };
// DEPRECATED: Used the global interface accessors instead! // DEPRECATED: Used the global interface accessors instead!
// //
// This will be removed in a future iteration of the SDK // This will be removed in a future iteration of the SDK
class CSteamAPIContext class CSteamAPIContext {
{
public: public:
CSteamAPIContext() { Clear(); } CSteamAPIContext() { Clear(); }
inline void Clear() { memset( this, 0, sizeof(*this) ); } inline void Clear() { memset(this, 0, sizeof(*this)); }
inline bool Init(); // NOTE: This is defined in steam_api.h, to avoid this file having to include everything inline bool Init(); // NOTE: This is defined in steam_api.h, to avoid this file having to include everything
ISteamClient* SteamClient() const { return m_pSteamClient; } ISteamClient* SteamClient() const { return m_pSteamClient; }
ISteamUser* SteamUser() const { return m_pSteamUser; } ISteamUser* SteamUser() const { return m_pSteamUser; }
ISteamFriends* SteamFriends() const { return m_pSteamFriends; } ISteamFriends* SteamFriends() const { return m_pSteamFriends; }
ISteamUtils* SteamUtils() const { return m_pSteamUtils; } ISteamUtils* SteamUtils() const { return m_pSteamUtils; }
ISteamMatchmaking* SteamMatchmaking() const { return m_pSteamMatchmaking; } ISteamMatchmaking* SteamMatchmaking() const { return m_pSteamMatchmaking; }
ISteamGameSearch* SteamGameSearch() const { return m_pSteamGameSearch; } ISteamGameSearch* SteamGameSearch() const { return m_pSteamGameSearch; }
ISteamUserStats* SteamUserStats() const { return m_pSteamUserStats; } ISteamUserStats* SteamUserStats() const { return m_pSteamUserStats; }
ISteamApps* SteamApps() const { return m_pSteamApps; } ISteamApps* SteamApps() const { return m_pSteamApps; }
ISteamMatchmakingServers* SteamMatchmakingServers() const { return m_pSteamMatchmakingServers; } ISteamMatchmakingServers* SteamMatchmakingServers() const { return m_pSteamMatchmakingServers; }
ISteamNetworking* SteamNetworking() const { return m_pSteamNetworking; } ISteamNetworking* SteamNetworking() const { return m_pSteamNetworking; }
ISteamRemoteStorage* SteamRemoteStorage() const { return m_pSteamRemoteStorage; } ISteamRemoteStorage* SteamRemoteStorage() const { return m_pSteamRemoteStorage; }
ISteamScreenshots* SteamScreenshots() const { return m_pSteamScreenshots; } ISteamScreenshots* SteamScreenshots() const { return m_pSteamScreenshots; }
ISteamHTTP* SteamHTTP() const { return m_pSteamHTTP; } ISteamHTTP* SteamHTTP() const { return m_pSteamHTTP; }
ISteamController* SteamController() const { return m_pController; } ISteamController* SteamController() const { return m_pController; }
ISteamUGC* SteamUGC() const { return m_pSteamUGC; } ISteamUGC* SteamUGC() const { return m_pSteamUGC; }
ISteamAppList* SteamAppList() const { return m_pSteamAppList; } ISteamAppList* SteamAppList() const { return m_pSteamAppList; }
ISteamMusic* SteamMusic() const { return m_pSteamMusic; } ISteamMusic* SteamMusic() const { return m_pSteamMusic; }
ISteamMusicRemote* SteamMusicRemote() const { return m_pSteamMusicRemote; } ISteamMusicRemote* SteamMusicRemote() const { return m_pSteamMusicRemote; }
ISteamHTMLSurface* SteamHTMLSurface() const { return m_pSteamHTMLSurface; } ISteamHTMLSurface* SteamHTMLSurface() const { return m_pSteamHTMLSurface; }
ISteamInventory* SteamInventory() const { return m_pSteamInventory; } ISteamInventory* SteamInventory() const { return m_pSteamInventory; }
ISteamVideo* SteamVideo() const { return m_pSteamVideo; } ISteamVideo* SteamVideo() const { return m_pSteamVideo; }
ISteamParentalSettings* SteamParentalSettings() const { return m_pSteamParentalSettings; } ISteamParentalSettings* SteamParentalSettings() const { return m_pSteamParentalSettings; }
ISteamInput* SteamInput() const { return m_pSteamInput; } ISteamInput* SteamInput() const { return m_pSteamInput; }
private:
ISteamClient *m_pSteamClient;
ISteamUser *m_pSteamUser;
ISteamFriends *m_pSteamFriends;
ISteamUtils *m_pSteamUtils;
ISteamMatchmaking *m_pSteamMatchmaking;
ISteamGameSearch *m_pSteamGameSearch;
ISteamUserStats *m_pSteamUserStats;
ISteamApps *m_pSteamApps;
ISteamMatchmakingServers *m_pSteamMatchmakingServers;
ISteamNetworking *m_pSteamNetworking;
ISteamRemoteStorage *m_pSteamRemoteStorage;
ISteamScreenshots *m_pSteamScreenshots;
ISteamHTTP *m_pSteamHTTP;
ISteamController *m_pController;
ISteamUGC *m_pSteamUGC;
ISteamAppList *m_pSteamAppList;
ISteamMusic *m_pSteamMusic;
ISteamMusicRemote *m_pSteamMusicRemote;
ISteamHTMLSurface *m_pSteamHTMLSurface;
ISteamInventory *m_pSteamInventory;
ISteamVideo *m_pSteamVideo;
ISteamParentalSettings *m_pSteamParentalSettings;
ISteamInput *m_pSteamInput;
};
class CSteamGameServerAPIContext
{
public:
CSteamGameServerAPIContext() { Clear(); }
inline void Clear() { memset( this, 0, sizeof(*this) ); }
inline bool Init(); // NOTE: This is defined in steam_gameserver.h, to avoid this file having to include everything
ISteamClient *SteamClient() const { return m_pSteamClient; }
ISteamGameServer *SteamGameServer() const { return m_pSteamGameServer; }
ISteamUtils *SteamGameServerUtils() const { return m_pSteamGameServerUtils; }
ISteamNetworking *SteamGameServerNetworking() const { return m_pSteamGameServerNetworking; }
ISteamGameServerStats *SteamGameServerStats() const { return m_pSteamGameServerStats; }
ISteamHTTP *SteamHTTP() const { return m_pSteamHTTP; }
ISteamInventory *SteamInventory() const { return m_pSteamInventory; }
ISteamUGC *SteamUGC() const { return m_pSteamUGC; }
ISteamApps *SteamApps() const { return m_pSteamApps; }
private: private:
ISteamClient *m_pSteamClient; ISteamClient* m_pSteamClient;
ISteamGameServer *m_pSteamGameServer; ISteamUser* m_pSteamUser;
ISteamUtils *m_pSteamGameServerUtils; ISteamFriends* m_pSteamFriends;
ISteamNetworking *m_pSteamGameServerNetworking; ISteamUtils* m_pSteamUtils;
ISteamGameServerStats *m_pSteamGameServerStats; ISteamMatchmaking* m_pSteamMatchmaking;
ISteamHTTP *m_pSteamHTTP; ISteamGameSearch* m_pSteamGameSearch;
ISteamInventory *m_pSteamInventory; ISteamUserStats* m_pSteamUserStats;
ISteamUGC *m_pSteamUGC; ISteamApps* m_pSteamApps;
ISteamApps *m_pSteamApps; ISteamMatchmakingServers* m_pSteamMatchmakingServers;
ISteamNetworking* m_pSteamNetworking;
ISteamRemoteStorage* m_pSteamRemoteStorage;
ISteamScreenshots* m_pSteamScreenshots;
ISteamHTTP* m_pSteamHTTP;
ISteamController* m_pController;
ISteamUGC* m_pSteamUGC;
ISteamAppList* m_pSteamAppList;
ISteamMusic* m_pSteamMusic;
ISteamMusicRemote* m_pSteamMusicRemote;
ISteamHTMLSurface* m_pSteamHTMLSurface;
ISteamInventory* m_pSteamInventory;
ISteamVideo* m_pSteamVideo;
ISteamParentalSettings* m_pSteamParentalSettings;
ISteamInput* m_pSteamInput;
}; };
class CSteamGameServerAPIContext {
public:
CSteamGameServerAPIContext() { Clear(); }
inline void Clear() { memset(this, 0, sizeof(*this)); }
inline bool Init(); // NOTE: This is defined in steam_gameserver.h, to avoid this file having to include everything
ISteamClient* SteamClient() const { return m_pSteamClient; }
ISteamGameServer* SteamGameServer() const { return m_pSteamGameServer; }
ISteamUtils* SteamGameServerUtils() const { return m_pSteamGameServerUtils; }
ISteamNetworking* SteamGameServerNetworking() const { return m_pSteamGameServerNetworking; }
ISteamGameServerStats* SteamGameServerStats() const { return m_pSteamGameServerStats; }
ISteamHTTP* SteamHTTP() const { return m_pSteamHTTP; }
ISteamInventory* SteamInventory() const { return m_pSteamInventory; }
ISteamUGC* SteamUGC() const { return m_pSteamUGC; }
ISteamApps* SteamApps() const { return m_pSteamApps; }
private:
ISteamClient* m_pSteamClient;
ISteamGameServer* m_pSteamGameServer;
ISteamUtils* m_pSteamGameServerUtils;
ISteamNetworking* m_pSteamGameServerNetworking;
ISteamGameServerStats* m_pSteamGameServerStats;
ISteamHTTP* m_pSteamHTTP;
ISteamInventory* m_pSteamInventory;
ISteamUGC* m_pSteamUGC;
ISteamApps* m_pSteamApps;
};

View File

@ -1,6 +1,6 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======= //====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
// //
// Purpose: // Purpose:
// //
//============================================================================= //=============================================================================
@ -10,23 +10,22 @@
#pragma once #pragma once
#endif #endif
#include "steam_api.h"
#include "isteamgameserver.h" #include "isteamgameserver.h"
#include "isteamgameserverstats.h" #include "isteamgameserverstats.h"
#include "steam_api.h"
enum EServerMode enum EServerMode {
{ eServerModeInvalid = 0, // DO NOT USE
eServerModeInvalid = 0, // DO NOT USE eServerModeNoAuthentication = 1, // Don't authenticate user logins and don't list on the server list
eServerModeNoAuthentication = 1, // Don't authenticate user logins and don't list on the server list eServerModeAuthentication = 2, // Authenticate users, list on the server list, don't run VAC on clients that connect
eServerModeAuthentication = 2, // Authenticate users, list on the server list, don't run VAC on clients that connect eServerModeAuthenticationAndSecure = 3, // Authenticate users, list on the server list and VAC protect clients
eServerModeAuthenticationAndSecure = 3, // Authenticate users, list on the server list and VAC protect clients };
};
/// Pass to SteamGameServer_Init to indicate that the same UDP port will be used for game traffic /// Pass to SteamGameServer_Init to indicate that the same UDP port will be used for game traffic
/// UDP queries. In this case, Steam will not open up a socket to handle server browser queries, /// UDP queries. In this case, Steam will not open up a socket to handle server browser queries,
/// and you must use ISteamGameServer::HandleIncomingPacket and ISteamGameServer::GetNextOutgoingPacket /// and you must use ISteamGameServer::HandleIncomingPacket and ISteamGameServer::GetNextOutgoingPacket
/// to handle packets related to server discovery on your socket. /// to handle packets related to server discovery on your socket.
#define MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE ((uint16)-1) #define MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE ((uint16)-1)
// Initialize SteamGameServer client and interface objects, and set server properties which may not be changed. // Initialize SteamGameServer client and interface objects, and set server properties which may not be changed.
// //
@ -44,7 +43,7 @@ enum EServerMode
// UDP packets for the master server updater. See references to GameSocketShare in isteamgameserver.h. // UDP packets for the master server updater. See references to GameSocketShare in isteamgameserver.h.
// - The version string should be in the form x.x.x.x, and is used by the master server to detect when the // - The version string should be in the form x.x.x.x, and is used by the master server to detect when the
// server is out of date. (Only servers with the latest version will be listed.) // server is out of date. (Only servers with the latest version will be listed.)
inline bool SteamGameServer_Init( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ); inline bool SteamGameServer_Init(uint32 unIP, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char* pchVersionString);
// Shutdown SteamGameSeverXxx interfaces, log out, and free resources. // Shutdown SteamGameSeverXxx interfaces, log out, and free resources.
S_API void SteamGameServer_Shutdown(); S_API void SteamGameServer_Shutdown();
@ -78,37 +77,37 @@ S_API uint64 SteamGameServer_GetSteamID();
// This function must be declared inline in the header so the module using steam_api.dll gets the version names they want. // This function must be declared inline in the header so the module using steam_api.dll gets the version names they want.
inline bool CSteamGameServerAPIContext::Init() inline bool CSteamGameServerAPIContext::Init()
{ {
m_pSteamClient = ::SteamGameServerClient(); m_pSteamClient = ::SteamGameServerClient();
if ( !m_pSteamClient ) if (!m_pSteamClient)
return false; return false;
m_pSteamGameServer = ::SteamGameServer(); m_pSteamGameServer = ::SteamGameServer();
m_pSteamGameServerUtils = ::SteamGameServerUtils(); m_pSteamGameServerUtils = ::SteamGameServerUtils();
m_pSteamGameServerNetworking = ::SteamGameServerNetworking(); m_pSteamGameServerNetworking = ::SteamGameServerNetworking();
m_pSteamGameServerStats = ::SteamGameServerStats(); m_pSteamGameServerStats = ::SteamGameServerStats();
m_pSteamHTTP = ::SteamGameServerHTTP(); m_pSteamHTTP = ::SteamGameServerHTTP();
m_pSteamInventory = ::SteamGameServerInventory(); m_pSteamInventory = ::SteamGameServerInventory();
m_pSteamUGC = ::SteamGameServerUGC(); m_pSteamUGC = ::SteamGameServerUGC();
m_pSteamApps = ::SteamGameServerApps(); m_pSteamApps = ::SteamGameServerApps();
if ( !m_pSteamGameServer || !m_pSteamGameServerUtils || !m_pSteamGameServerNetworking || !m_pSteamGameServerStats if (!m_pSteamGameServer || !m_pSteamGameServerUtils || !m_pSteamGameServerNetworking || !m_pSteamGameServerStats
|| !m_pSteamHTTP || !m_pSteamInventory || !m_pSteamUGC || !m_pSteamApps ) || !m_pSteamHTTP || !m_pSteamInventory || !m_pSteamUGC || !m_pSteamApps)
return false; return false;
return true; return true;
} }
#endif #endif
S_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16 usLegacySteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ); S_API bool S_CALLTYPE SteamInternal_GameServer_Init(uint32 unIP, uint16 usLegacySteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char* pchVersionString);
inline bool SteamGameServer_Init( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ) inline bool SteamGameServer_Init(uint32 unIP, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char* pchVersionString)
{ {
if ( !SteamInternal_GameServer_Init( unIP, 0, usGamePort, usQueryPort, eServerMode, pchVersionString ) ) if (!SteamInternal_GameServer_Init(unIP, 0, usGamePort, usQueryPort, eServerMode, pchVersionString))
return false; return false;
return true; return true;
} }
inline void SteamGameServer_ReleaseCurrentThreadMemory() inline void SteamGameServer_ReleaseCurrentThreadMemory()
{ {
SteamAPI_ReleaseCurrentThreadMemory(); SteamAPI_ReleaseCurrentThreadMemory();
} }
#endif // STEAM_GAMESERVER_H #endif // STEAM_GAMESERVER_H

File diff suppressed because it is too large Load Diff

View File

@ -12,16 +12,16 @@
#endif #endif
#ifndef assert #ifndef assert
#include <assert.h> #include <assert.h>
#endif #endif
#include <string.h>
#include "steamnetworkingtypes.h" #include "steamnetworkingtypes.h"
#include <string.h>
#if defined( VALVE_CALLBACK_PACK_SMALL ) #if defined(VALVE_CALLBACK_PACK_SMALL)
#pragma pack( push, 4 ) #pragma pack(push, 4)
#elif defined( VALVE_CALLBACK_PACK_LARGE ) #elif defined(VALVE_CALLBACK_PACK_LARGE)
#pragma pack( push, 8 ) #pragma pack(push, 8)
#else #else
#error "Must define VALVE_CALLBACK_PACK_SMALL or VALVE_CALLBACK_PACK_LARGE" #error "Must define VALVE_CALLBACK_PACK_SMALL or VALVE_CALLBACK_PACK_LARGE"
#endif #endif
@ -36,207 +36,206 @@ const size_t k_cbSteamDatagramMaxSerializedTicket = 512;
/// to the intended destination, but otherwise clients really should not /// to the intended destination, but otherwise clients really should not
/// need to know what's inside. (Indeed, we don't really want them to /// need to know what's inside. (Indeed, we don't really want them to
/// know, as it could reveal information useful to an attacker.) /// know, as it could reveal information useful to an attacker.)
struct SteamDatagramHostedAddress struct SteamDatagramHostedAddress {
{
// Size of data blob. // Size of data blob.
int m_cbSize; int m_cbSize;
// Opaque data // Opaque data
char m_data[ 128 ]; char m_data[128];
// Reset to empty state // Reset to empty state
void Clear() { memset( this, 0, sizeof(*this) ); } void Clear() { memset(this, 0, sizeof(*this)); }
// Parse the data center out of the blob. // Parse the data center out of the blob.
SteamNetworkingPOPID GetPopID() const { return CalculateSteamNetworkingPOPIDFromString( m_data ); } SteamNetworkingPOPID GetPopID() const { return CalculateSteamNetworkingPOPIDFromString(m_data); }
/// Set a dummy routing blob with a hardcoded IP:port. You should only use /// Set a dummy routing blob with a hardcoded IP:port. You should only use
/// this in a dev environment, since the address is in plaintext! /// this in a dev environment, since the address is in plaintext!
/// In production this information should come from the server, /// In production this information should come from the server,
/// using ISteamNetworkingSockets::GetHostedDedicatedServerAddress /// using ISteamNetworkingSockets::GetHostedDedicatedServerAddress
void SetDevAddress( uint32 nIP, uint16 nPort, SteamNetworkingPOPID popid = 0 ) void SetDevAddress(uint32 nIP, uint16 nPort, SteamNetworkingPOPID popid = 0)
{ {
GetSteamNetworkingLocationPOPStringFromID( popid, m_data ); GetSteamNetworkingLocationPOPStringFromID(popid, m_data);
m_cbSize = 4; m_cbSize = 4;
m_data[m_cbSize++] = 1; m_data[m_cbSize++] = 1;
m_data[m_cbSize++] = 1; m_data[m_cbSize++] = 1;
m_data[m_cbSize++] = char(nPort); m_data[m_cbSize++] = char(nPort);
m_data[m_cbSize++] = char(nPort>>8); m_data[m_cbSize++] = char(nPort >> 8);
m_data[m_cbSize++] = char(nIP); m_data[m_cbSize++] = char(nIP);
m_data[m_cbSize++] = char(nIP>>8); m_data[m_cbSize++] = char(nIP >> 8);
m_data[m_cbSize++] = char(nIP>>16); m_data[m_cbSize++] = char(nIP >> 16);
m_data[m_cbSize++] = char(nIP>>24); m_data[m_cbSize++] = char(nIP >> 24);
} }
/// Convert to/from std::string (or anything that acts like it). /// Convert to/from std::string (or anything that acts like it).
/// Useful for interfacing with google protobuf. It's a template /// Useful for interfacing with google protobuf. It's a template
/// mainly so that we don't have to include <string> in the header. /// mainly so that we don't have to include <string> in the header.
/// Note: by "string", we don't mean that it's text. It's a binary /// Note: by "string", we don't mean that it's text. It's a binary
/// blob, and it might have zeros in it. (std::string can handle that.) /// blob, and it might have zeros in it. (std::string can handle that.)
template <typename T> bool SetFromStdString( const T &str ) template <typename T>
{ bool SetFromStdString(const T& str)
if ( str.length() >= sizeof(m_data) ) {
{ if (str.length() >= sizeof(m_data)) {
m_cbSize = 0; m_cbSize = 0;
return false; return false;
} }
m_cbSize = (int)str.length(); m_cbSize = (int)str.length();
memcpy( m_data, str.c_str(), m_cbSize ); memcpy(m_data, str.c_str(), m_cbSize);
return true; return true;
} }
template <typename T> void GetAsStdString( T *str ) const template <typename T>
{ void GetAsStdString(T* str) const
str->assign( m_data, m_cbSize ); {
} str->assign(m_data, m_cbSize);
}
}; };
/// Ticket used to gain access to the relay network. /// Ticket used to gain access to the relay network.
struct SteamDatagramRelayAuthTicket struct SteamDatagramRelayAuthTicket {
{ SteamDatagramRelayAuthTicket() { Clear(); }
SteamDatagramRelayAuthTicket() { Clear(); }
/// Reset all fields /// Reset all fields
void Clear() { memset( this, 0, sizeof(*this) ); m_nRestrictToVirtualPort = -1; } void Clear()
{
memset(this, 0, sizeof(*this));
m_nRestrictToVirtualPort = -1;
}
/// Identity of the gameserver we want to talk to. This is required. /// Identity of the gameserver we want to talk to. This is required.
SteamNetworkingIdentity m_identityGameserver; SteamNetworkingIdentity m_identityGameserver;
/// Identity of the person who was authorized. This is required. /// Identity of the person who was authorized. This is required.
SteamNetworkingIdentity m_identityAuthorizedClient; SteamNetworkingIdentity m_identityAuthorizedClient;
/// SteamID is authorized to send from a particular public IP. If this /// SteamID is authorized to send from a particular public IP. If this
/// is 0, then the sender is not restricted to a particular IP. /// is 0, then the sender is not restricted to a particular IP.
/// ///
/// Recommend to leave this set to zero. /// Recommend to leave this set to zero.
uint32 m_unPublicIP; uint32 m_unPublicIP;
/// Time when the ticket expires. Recommended: take the current /// Time when the ticket expires. Recommended: take the current
/// time and add 6 hours, or maybe a bit longer if your gameplay /// time and add 6 hours, or maybe a bit longer if your gameplay
/// sessions are longer. /// sessions are longer.
/// ///
/// NOTE: relays may reject tickets with expiry times excessively /// NOTE: relays may reject tickets with expiry times excessively
/// far in the future, so contact us if you wish to use an expiry /// far in the future, so contact us if you wish to use an expiry
/// longer than, say, 24 hours. /// longer than, say, 24 hours.
RTime32 m_rtimeTicketExpiry; RTime32 m_rtimeTicketExpiry;
/// Routing information where the gameserver is listening for /// Routing information where the gameserver is listening for
/// relayed traffic. You should fill this in when generating /// relayed traffic. You should fill this in when generating
/// a ticket. /// a ticket.
/// ///
/// When generating tickets on your backend: /// When generating tickets on your backend:
/// - In production: The gameserver knows the proper routing /// - In production: The gameserver knows the proper routing
/// information, so you need to call /// information, so you need to call
/// ISteamNetworkingSockets::GetHostedDedicatedServerAddress /// ISteamNetworkingSockets::GetHostedDedicatedServerAddress
/// and send the info to your backend. /// and send the info to your backend.
/// - In development, you will need to provide public IP /// - In development, you will need to provide public IP
/// of the server using SteamDatagramServiceNetID::SetDevAddress. /// of the server using SteamDatagramServiceNetID::SetDevAddress.
/// Relays need to be able to send UDP /// Relays need to be able to send UDP
/// packets to this server. Since it's very likely that /// packets to this server. Since it's very likely that
/// your server is behind a firewall/NAT, make sure that /// your server is behind a firewall/NAT, make sure that
/// the address is the one that the outside world can use. /// the address is the one that the outside world can use.
/// The traffic from the relays will be "unsolicited", so /// The traffic from the relays will be "unsolicited", so
/// stateful firewalls won't work -- you will probably have /// stateful firewalls won't work -- you will probably have
/// to set up an explicit port forward. /// to set up an explicit port forward.
/// On the client: /// On the client:
/// - this field will always be blank. /// - this field will always be blank.
SteamDatagramHostedAddress m_routing; SteamDatagramHostedAddress m_routing;
/// App ID this is for. This is required, and should be the /// App ID this is for. This is required, and should be the
/// App ID the client is running. (Even if your gameserver /// App ID the client is running. (Even if your gameserver
/// uses a different App ID.) /// uses a different App ID.)
uint32 m_nAppID; uint32 m_nAppID;
/// Restrict this ticket to be used for a particular virtual port? /// Restrict this ticket to be used for a particular virtual port?
/// Set to -1 to allow any virtual port. /// Set to -1 to allow any virtual port.
/// ///
/// This is useful as a security measure, and also so the client will /// This is useful as a security measure, and also so the client will
/// use the right ticket (which might have extra fields that are useful /// use the right ticket (which might have extra fields that are useful
/// for proper analytics), if the client happens to have more than one /// for proper analytics), if the client happens to have more than one
/// appropriate ticket. /// appropriate ticket.
/// ///
/// Note: if a client has more that one acceptable ticket, they will /// Note: if a client has more that one acceptable ticket, they will
/// always use the one expiring the latest. /// always use the one expiring the latest.
int m_nRestrictToVirtualPort; int m_nRestrictToVirtualPort;
// //
// Extra fields. // Extra fields.
// //
// These are collected for backend analytics. For example, you might // These are collected for backend analytics. For example, you might
// send a MatchID so that all of the records for a particular match can // send a MatchID so that all of the records for a particular match can
// be located. Or send a game mode field so that you can compare // be located. Or send a game mode field so that you can compare
// the network characteristics of different game modes. // the network characteristics of different game modes.
// //
// (At the time of this writing we don't have a way to expose the data // (At the time of this writing we don't have a way to expose the data
// we collect to partners, but we hope to in the future so that you can // we collect to partners, but we hope to in the future so that you can
// get visibility into network conditions.) // get visibility into network conditions.)
// //
struct ExtraField struct ExtraField {
{ enum EType {
enum EType k_EType_String,
{ k_EType_Int, // For most small integral values. Uses google protobuf sint64, so it's small on the wire. WARNING: In some places this value may be transmitted in JSON, in which case precision may be lost in backend analytics. Don't use this for an "identifier", use it for a scalar quantity.
k_EType_String, k_EType_Fixed64, // 64 arbitrary bits. This value is treated as an "identifier". In places where JSON format is used, it will be serialized as a string. No aggregation / analytics can be performed on this value.
k_EType_Int, // For most small integral values. Uses google protobuf sint64, so it's small on the wire. WARNING: In some places this value may be transmitted in JSON, in which case precision may be lost in backend analytics. Don't use this for an "identifier", use it for a scalar quantity. };
k_EType_Fixed64, // 64 arbitrary bits. This value is treated as an "identifier". In places where JSON format is used, it will be serialized as a string. No aggregation / analytics can be performed on this value. int /* EType */ m_eType;
}; char m_szName[28];
int /* EType */ m_eType;
char m_szName[28];
union { union {
char m_szStringValue[128]; char m_szStringValue[128];
int64 m_nIntValue; int64 m_nIntValue;
uint64 m_nFixed64Value; uint64 m_nFixed64Value;
}; };
}; };
enum { k_nMaxExtraFields = 16 }; enum { k_nMaxExtraFields = 16 };
int m_nExtraFields; int m_nExtraFields;
ExtraField m_vecExtraFields[ k_nMaxExtraFields ]; ExtraField m_vecExtraFields[k_nMaxExtraFields];
/// Helper to add an extra field in a single call /// Helper to add an extra field in a single call
void AddExtraField_Int( const char *pszName, int64 val ) void AddExtraField_Int(const char* pszName, int64 val)
{ {
ExtraField *p = AddExtraField( pszName, ExtraField::k_EType_Int ); ExtraField* p = AddExtraField(pszName, ExtraField::k_EType_Int);
if ( p ) if (p)
p->m_nIntValue = val; p->m_nIntValue = val;
} }
void AddExtraField_Fixed64( const char *pszName, uint64 val ) void AddExtraField_Fixed64(const char* pszName, uint64 val)
{ {
ExtraField *p = AddExtraField( pszName, ExtraField::k_EType_Fixed64 ); ExtraField* p = AddExtraField(pszName, ExtraField::k_EType_Fixed64);
if ( p ) if (p)
p->m_nFixed64Value = val; p->m_nFixed64Value = val;
} }
void AddExtraField_String( const char *pszName, const char *val ) void AddExtraField_String(const char* pszName, const char* val)
{ {
ExtraField *p = AddExtraField( pszName, ExtraField::k_EType_String ); ExtraField* p = AddExtraField(pszName, ExtraField::k_EType_String);
if ( p ) if (p) {
{ size_t l = strlen(val);
size_t l = strlen( val ); if (l > sizeof(p->m_szStringValue) - 1)
if ( l > sizeof(p->m_szStringValue)-1 ) l = sizeof(p->m_szStringValue) - 1;
l = sizeof(p->m_szStringValue)-1; memcpy(p->m_szStringValue, val, l);
memcpy( p->m_szStringValue, val, l ); p->m_szStringValue[l] = '\0';
p->m_szStringValue[l] = '\0'; }
} }
}
private: private:
ExtraField *AddExtraField( const char *pszName, ExtraField::EType eType ) ExtraField* AddExtraField(const char* pszName, ExtraField::EType eType)
{ {
if ( m_nExtraFields >= k_nMaxExtraFields ) if (m_nExtraFields >= k_nMaxExtraFields) {
{ assert(false);
assert( false ); return NULL;
return NULL; }
} ExtraField* p = &m_vecExtraFields[m_nExtraFields++];
ExtraField *p = &m_vecExtraFields[ m_nExtraFields++ ]; p->m_eType = eType;
p->m_eType = eType;
size_t l = strlen( pszName ); size_t l = strlen(pszName);
if ( l > sizeof(p->m_szName)-1 ) if (l > sizeof(p->m_szName) - 1)
l = sizeof(p->m_szName)-1; l = sizeof(p->m_szName) - 1;
memcpy( p->m_szName, pszName, l ); memcpy(p->m_szName, pszName, l);
p->m_szName[l] = '\0'; p->m_szName[l] = '\0';
return p; return p;
} }
}; };
#pragma pack(pop) #pragma pack(pop)
@ -260,27 +259,26 @@ const size_t k_cbMaxSteamDatagramGameCoordinatorServerLoginSerialized = 4096;
/// whitelists or tables of IP addresses. /// whitelists or tables of IP addresses.
/// ///
/// See ISteamNetworkingSockets::GetGameCoordinatorServerLogin /// See ISteamNetworkingSockets::GetGameCoordinatorServerLogin
struct SteamDatagramGameCoordinatorServerLogin struct SteamDatagramGameCoordinatorServerLogin {
{ /// Server's identity
/// Server's identity SteamNetworkingIdentity m_identity;
SteamNetworkingIdentity m_identity;
/// Routing info. Note that this includes the POPID /// Routing info. Note that this includes the POPID
SteamDatagramHostedAddress m_routing; SteamDatagramHostedAddress m_routing;
/// AppID that the server thinks it is running /// AppID that the server thinks it is running
AppId_t m_nAppID; AppId_t m_nAppID;
/// Unix timestamp when this was generated /// Unix timestamp when this was generated
RTime32 m_rtime; RTime32 m_rtime;
/// Size of application data /// Size of application data
int m_cbAppData; int m_cbAppData;
/// Application data. This is any additional information /// Application data. This is any additional information
/// that you need to identify the server not contained above. /// that you need to identify the server not contained above.
/// (E.g. perhaps a public IP as seen by the coordinator service.) /// (E.g. perhaps a public IP as seen by the coordinator service.)
char m_appData[ k_cbMaxSteamDatagramGameCoordinatorServerLoginAppData ]; char m_appData[k_cbMaxSteamDatagramGameCoordinatorServerLoginAppData];
}; };
#endif // STEAMDATAGRAM_TICKETS_H #endif // STEAMDATAGRAM_TICKETS_H

View File

@ -2,39 +2,38 @@
// //
// Purpose: utilities to decode/decrypt a ticket from the // Purpose: utilities to decode/decrypt a ticket from the
// ISteamUser::RequestEncryptedAppTicket, ISteamUser::GetEncryptedAppTicket API // ISteamUser::RequestEncryptedAppTicket, ISteamUser::GetEncryptedAppTicket API
// //
// To use: declare CSteamEncryptedAppTicket, then call BDecryptTicket // To use: declare CSteamEncryptedAppTicket, then call BDecryptTicket
// if BDecryptTicket returns true, other accessors are valid // if BDecryptTicket returns true, other accessors are valid
// //
//============================================================================= //=============================================================================
#include "steam_api.h" #include "steam_api.h"
static const int k_nSteamEncryptedAppTicketSymmetricKeyLen = 32; static const int k_nSteamEncryptedAppTicketSymmetricKeyLen = 32;
S_API bool SteamEncryptedAppTicket_BDecryptTicket(const uint8* rgubTicketEncrypted, uint32 cubTicketEncrypted,
uint8* rgubTicketDecrypted, uint32* pcubTicketDecrypted,
const uint8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], int cubKey);
S_API bool SteamEncryptedAppTicket_BDecryptTicket( const uint8 *rgubTicketEncrypted, uint32 cubTicketEncrypted, S_API bool SteamEncryptedAppTicket_BIsTicketForApp(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID);
uint8 *rgubTicketDecrypted, uint32 *pcubTicketDecrypted,
const uint8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], int cubKey );
S_API bool SteamEncryptedAppTicket_BIsTicketForApp( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID ); S_API RTime32 SteamEncryptedAppTicket_GetTicketIssueTime(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted);
S_API RTime32 SteamEncryptedAppTicket_GetTicketIssueTime( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); S_API void SteamEncryptedAppTicket_GetTicketSteamID(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted, CSteamID* psteamID);
S_API void SteamEncryptedAppTicket_GetTicketSteamID( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, CSteamID *psteamID ); S_API AppId_t SteamEncryptedAppTicket_GetTicketAppID(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted);
S_API AppId_t SteamEncryptedAppTicket_GetTicketAppID( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); S_API bool SteamEncryptedAppTicket_BUserOwnsAppInTicket(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID);
S_API bool SteamEncryptedAppTicket_BUserOwnsAppInTicket( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID ); S_API bool SteamEncryptedAppTicket_BUserIsVacBanned(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted);
S_API bool SteamEncryptedAppTicket_BUserIsVacBanned( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); S_API bool SteamEncryptedAppTicket_BGetAppDefinedValue(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted, uint32* pValue);
S_API bool SteamEncryptedAppTicket_BGetAppDefinedValue( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, uint32 *pValue ); S_API const uint8* SteamEncryptedAppTicket_GetUserVariableData(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted, uint32* pcubUserData);
S_API const uint8 *SteamEncryptedAppTicket_GetUserVariableData( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, uint32 *pcubUserData ); S_API bool SteamEncryptedAppTicket_BIsTicketSigned(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted, const uint8* pubRSAKey, uint32 cubRSAKey);
S_API bool SteamEncryptedAppTicket_BIsTicketSigned( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, const uint8 *pubRSAKey, uint32 cubRSAKey ); S_API bool SteamEncryptedAppTicket_BIsLicenseBorrowed(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted);
S_API bool SteamEncryptedAppTicket_BIsLicenseBorrowed( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); S_API bool SteamEncryptedAppTicket_BIsLicenseTemporary(uint8* rgubTicketDecrypted, uint32 cubTicketDecrypted);
S_API bool SteamEncryptedAppTicket_BIsLicenseTemporary( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted );

View File

@ -14,86 +14,83 @@
// HTTP related types // HTTP related types
// This enum is used in client API methods, do not re-number existing values. // This enum is used in client API methods, do not re-number existing values.
enum EHTTPMethod enum EHTTPMethod {
{ k_EHTTPMethodInvalid = 0,
k_EHTTPMethodInvalid = 0, k_EHTTPMethodGET,
k_EHTTPMethodGET, k_EHTTPMethodHEAD,
k_EHTTPMethodHEAD, k_EHTTPMethodPOST,
k_EHTTPMethodPOST, k_EHTTPMethodPUT,
k_EHTTPMethodPUT, k_EHTTPMethodDELETE,
k_EHTTPMethodDELETE, k_EHTTPMethodOPTIONS,
k_EHTTPMethodOPTIONS, k_EHTTPMethodPATCH,
k_EHTTPMethodPATCH,
// The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for // The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for
// a compliant general purpose server. We'll likely add more as we find uses for them. // a compliant general purpose server. We'll likely add more as we find uses for them.
// k_EHTTPMethodTRACE, // k_EHTTPMethodTRACE,
// k_EHTTPMethodCONNECT // k_EHTTPMethodCONNECT
}; };
// HTTP Status codes that the server can send in response to a request, see rfc2616 section 10.3 for descriptions // HTTP Status codes that the server can send in response to a request, see rfc2616 section 10.3 for descriptions
// of each of these. // of each of these.
enum EHTTPStatusCode enum EHTTPStatusCode {
{ // Invalid status code (this isn't defined in HTTP, used to indicate unset in our code)
// Invalid status code (this isn't defined in HTTP, used to indicate unset in our code) k_EHTTPStatusCodeInvalid = 0,
k_EHTTPStatusCodeInvalid = 0,
// Informational codes // Informational codes
k_EHTTPStatusCode100Continue = 100, k_EHTTPStatusCode100Continue = 100,
k_EHTTPStatusCode101SwitchingProtocols = 101, k_EHTTPStatusCode101SwitchingProtocols = 101,
// Success codes // Success codes
k_EHTTPStatusCode200OK = 200, k_EHTTPStatusCode200OK = 200,
k_EHTTPStatusCode201Created = 201, k_EHTTPStatusCode201Created = 201,
k_EHTTPStatusCode202Accepted = 202, k_EHTTPStatusCode202Accepted = 202,
k_EHTTPStatusCode203NonAuthoritative = 203, k_EHTTPStatusCode203NonAuthoritative = 203,
k_EHTTPStatusCode204NoContent = 204, k_EHTTPStatusCode204NoContent = 204,
k_EHTTPStatusCode205ResetContent = 205, k_EHTTPStatusCode205ResetContent = 205,
k_EHTTPStatusCode206PartialContent = 206, k_EHTTPStatusCode206PartialContent = 206,
// Redirection codes // Redirection codes
k_EHTTPStatusCode300MultipleChoices = 300, k_EHTTPStatusCode300MultipleChoices = 300,
k_EHTTPStatusCode301MovedPermanently = 301, k_EHTTPStatusCode301MovedPermanently = 301,
k_EHTTPStatusCode302Found = 302, k_EHTTPStatusCode302Found = 302,
k_EHTTPStatusCode303SeeOther = 303, k_EHTTPStatusCode303SeeOther = 303,
k_EHTTPStatusCode304NotModified = 304, k_EHTTPStatusCode304NotModified = 304,
k_EHTTPStatusCode305UseProxy = 305, k_EHTTPStatusCode305UseProxy = 305,
//k_EHTTPStatusCode306Unused = 306, (used in old HTTP spec, now unused in 1.1) //k_EHTTPStatusCode306Unused = 306, (used in old HTTP spec, now unused in 1.1)
k_EHTTPStatusCode307TemporaryRedirect = 307, k_EHTTPStatusCode307TemporaryRedirect = 307,
// Error codes // Error codes
k_EHTTPStatusCode400BadRequest = 400, k_EHTTPStatusCode400BadRequest = 400,
k_EHTTPStatusCode401Unauthorized = 401, // You probably want 403 or something else. 401 implies you're sending a WWW-Authenticate header and the client can sent an Authorization header in response. k_EHTTPStatusCode401Unauthorized = 401, // You probably want 403 or something else. 401 implies you're sending a WWW-Authenticate header and the client can sent an Authorization header in response.
k_EHTTPStatusCode402PaymentRequired = 402, // This is reserved for future HTTP specs, not really supported by clients k_EHTTPStatusCode402PaymentRequired = 402, // This is reserved for future HTTP specs, not really supported by clients
k_EHTTPStatusCode403Forbidden = 403, k_EHTTPStatusCode403Forbidden = 403,
k_EHTTPStatusCode404NotFound = 404, k_EHTTPStatusCode404NotFound = 404,
k_EHTTPStatusCode405MethodNotAllowed = 405, k_EHTTPStatusCode405MethodNotAllowed = 405,
k_EHTTPStatusCode406NotAcceptable = 406, k_EHTTPStatusCode406NotAcceptable = 406,
k_EHTTPStatusCode407ProxyAuthRequired = 407, k_EHTTPStatusCode407ProxyAuthRequired = 407,
k_EHTTPStatusCode408RequestTimeout = 408, k_EHTTPStatusCode408RequestTimeout = 408,
k_EHTTPStatusCode409Conflict = 409, k_EHTTPStatusCode409Conflict = 409,
k_EHTTPStatusCode410Gone = 410, k_EHTTPStatusCode410Gone = 410,
k_EHTTPStatusCode411LengthRequired = 411, k_EHTTPStatusCode411LengthRequired = 411,
k_EHTTPStatusCode412PreconditionFailed = 412, k_EHTTPStatusCode412PreconditionFailed = 412,
k_EHTTPStatusCode413RequestEntityTooLarge = 413, k_EHTTPStatusCode413RequestEntityTooLarge = 413,
k_EHTTPStatusCode414RequestURITooLong = 414, k_EHTTPStatusCode414RequestURITooLong = 414,
k_EHTTPStatusCode415UnsupportedMediaType = 415, k_EHTTPStatusCode415UnsupportedMediaType = 415,
k_EHTTPStatusCode416RequestedRangeNotSatisfiable = 416, k_EHTTPStatusCode416RequestedRangeNotSatisfiable = 416,
k_EHTTPStatusCode417ExpectationFailed = 417, k_EHTTPStatusCode417ExpectationFailed = 417,
k_EHTTPStatusCode4xxUnknown = 418, // 418 is reserved, so we'll use it to mean unknown k_EHTTPStatusCode4xxUnknown = 418, // 418 is reserved, so we'll use it to mean unknown
k_EHTTPStatusCode429TooManyRequests = 429, k_EHTTPStatusCode429TooManyRequests = 429,
k_EHTTPStatusCode444ConnectionClosed = 444, // nginx only? k_EHTTPStatusCode444ConnectionClosed = 444, // nginx only?
// Server error codes // Server error codes
k_EHTTPStatusCode500InternalServerError = 500, k_EHTTPStatusCode500InternalServerError = 500,
k_EHTTPStatusCode501NotImplemented = 501, k_EHTTPStatusCode501NotImplemented = 501,
k_EHTTPStatusCode502BadGateway = 502, k_EHTTPStatusCode502BadGateway = 502,
k_EHTTPStatusCode503ServiceUnavailable = 503, k_EHTTPStatusCode503ServiceUnavailable = 503,
k_EHTTPStatusCode504GatewayTimeout = 504, k_EHTTPStatusCode504GatewayTimeout = 504,
k_EHTTPStatusCode505HTTPVersionNotSupported = 505, k_EHTTPStatusCode505HTTPVersionNotSupported = 505,
k_EHTTPStatusCode5xxUnknown = 599, k_EHTTPStatusCode5xxUnknown = 599,
}; };
#endif // STEAMHTTPENUMS_H #endif // STEAMHTTPENUMS_H

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
//====== Copyright 1996-2008, Valve Corporation, All rights reserved. ======= //====== Copyright 1996-2008, Valve Corporation, All rights reserved. =======
// //
// Purpose: // Purpose:
// //
//============================================================================= //=============================================================================
@ -22,91 +22,83 @@
#define STEAM_PS3_LANGUAGE_MAX 64 #define STEAM_PS3_LANGUAGE_MAX 64
#define STEAM_PS3_REGION_CODE_MAX 16 #define STEAM_PS3_REGION_CODE_MAX 16
#define STEAM_PS3_CURRENT_PARAMS_VER 2 #define STEAM_PS3_CURRENT_PARAMS_VER 2
struct SteamPS3Params_t struct SteamPS3Params_t {
{ uint32 m_unVersion; // set to STEAM_PS3_CURRENT_PARAMS_VER
uint32 m_unVersion; // set to STEAM_PS3_CURRENT_PARAMS_VER
void *pReserved;
uint32 m_nAppId; // set to your game's appid
char m_rgchInstallationPath[ STEAM_PS3_PATH_MAX ]; // directory containing latest steam prx's and sdata. Can be read only (BDVD) void* pReserved;
char m_rgchSystemCache[ STEAM_PS3_PATH_MAX ]; // temp working cache, not persistent uint32 m_nAppId; // set to your game's appid
char m_rgchGameData[ STEAM_PS3_PATH_MAX ]; // persistent game data path for storing user data
char m_rgchNpServiceID[ STEAM_PS3_SERVICE_ID_MAX ];
char m_rgchNpCommunicationID[ STEAM_PS3_COMMUNICATION_ID_MAX ];
char m_rgchNpCommunicationSig[ STEAM_PS3_COMMUNICATION_SIG_MAX ];
// Language should be one of the following. must be zero terminated char m_rgchInstallationPath[STEAM_PS3_PATH_MAX]; // directory containing latest steam prx's and sdata. Can be read only (BDVD)
// danish char m_rgchSystemCache[STEAM_PS3_PATH_MAX]; // temp working cache, not persistent
// dutch char m_rgchGameData[STEAM_PS3_PATH_MAX]; // persistent game data path for storing user data
// english char m_rgchNpServiceID[STEAM_PS3_SERVICE_ID_MAX];
// finnish char m_rgchNpCommunicationID[STEAM_PS3_COMMUNICATION_ID_MAX];
// french char m_rgchNpCommunicationSig[STEAM_PS3_COMMUNICATION_SIG_MAX];
// german
// italian
// korean
// norwegian
// polish
// portuguese
// russian
// schinese
// spanish
// swedish
// tchinese
char m_rgchSteamLanguage[ STEAM_PS3_LANGUAGE_MAX ];
// region codes are "SCEA", "SCEE", "SCEJ". must be zero terminated // Language should be one of the following. must be zero terminated
char m_rgchRegionCode[ STEAM_PS3_REGION_CODE_MAX ]; // danish
// dutch
// english
// finnish
// french
// german
// italian
// korean
// norwegian
// polish
// portuguese
// russian
// schinese
// spanish
// swedish
// tchinese
char m_rgchSteamLanguage[STEAM_PS3_LANGUAGE_MAX];
// Should be SYS_TTYP3 through SYS_TTYP10, if it's 0 then Steam won't spawn a // region codes are "SCEA", "SCEE", "SCEJ". must be zero terminated
// thread to read console input at all. Using this let's you use Steam console commands char m_rgchRegionCode[STEAM_PS3_REGION_CODE_MAX];
// like: profile_on, profile_off, profile_dump, mem_stats, mem_validate.
unsigned int m_cSteamInputTTY;
struct Ps3netInit_t // Should be SYS_TTYP3 through SYS_TTYP10, if it's 0 then Steam won't spawn a
{ // thread to read console input at all. Using this let's you use Steam console commands
bool m_bNeedInit; // like: profile_on, profile_off, profile_dump, mem_stats, mem_validate.
void *m_pMemory; unsigned int m_cSteamInputTTY;
int m_nMemorySize;
int m_flags;
} m_sysNetInitInfo;
struct Ps3jpgInit_t struct Ps3netInit_t {
{ bool m_bNeedInit;
bool m_bNeedInit; void* m_pMemory;
} m_sysJpgInitInfo; int m_nMemorySize;
int m_flags;
} m_sysNetInitInfo;
struct Ps3pngInit_t struct Ps3jpgInit_t {
{ bool m_bNeedInit;
bool m_bNeedInit; } m_sysJpgInitInfo;
} m_sysPngInitInfo;
struct Ps3sysutilUserInfo_t
{
bool m_bNeedInit;
} m_sysSysUtilUserInfo;
bool m_bIncludeNewsPage; struct Ps3pngInit_t {
bool m_bNeedInit;
} m_sysPngInitInfo;
struct Ps3sysutilUserInfo_t {
bool m_bNeedInit;
} m_sysSysUtilUserInfo;
bool m_bIncludeNewsPage;
}; };
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
// PlayStation 3 memory structure // PlayStation 3 memory structure
//----------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------------------------------------------------//
#define STEAMPS3_MALLOC_INUSE 0x53D04A51 #define STEAMPS3_MALLOC_INUSE 0x53D04A51
#define STEAMPS3_MALLOC_SYSTEM 0x0D102C48 #define STEAMPS3_MALLOC_SYSTEM 0x0D102C48
#define STEAMPS3_MALLOC_OK 0xFFD04A51 #define STEAMPS3_MALLOC_OK 0xFFD04A51
struct SteamPS3Memory_t struct SteamPS3Memory_t {
{ bool m_bSingleAllocation; // If true, Steam will request one 6MB allocation and use the returned memory for all future allocations
bool m_bSingleAllocation; // If true, Steam will request one 6MB allocation and use the returned memory for all future allocations // If false, Steam will make call malloc for each allocation
// If false, Steam will make call malloc for each allocation
// required function pointers // required function pointers
void* (*m_pfMalloc)(size_t); void* (*m_pfMalloc)(size_t);
void* (*m_pfRealloc)(void *, size_t); void* (*m_pfRealloc)(void*, size_t);
void (*m_pfFree)(void *); void (*m_pfFree)(void*);
size_t (*m_pUsable_size)(void*); size_t (*m_pUsable_size)(void*);
}; };
#endif // STEAMPS3PARAMS_H #endif // STEAMPS3PARAMS_H

View File

@ -17,11 +17,11 @@
typedef unsigned char uint8; typedef unsigned char uint8;
#endif #endif
#if defined( __GNUC__ ) && !defined(POSIX) #if defined(__GNUC__) && !defined(POSIX)
#if __GNUC__ < 4 #if __GNUC__ < 4
#error "Steamworks requires GCC 4.X (4.2 or 4.4 have been tested)" #error "Steamworks requires GCC 4.X (4.2 or 4.4 have been tested)"
#endif #endif
#define POSIX 1 #define POSIX 1
#endif #endif
#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) #if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__)
@ -36,7 +36,7 @@ typedef unsigned char uint8;
typedef unsigned char uint8; typedef unsigned char uint8;
typedef signed char int8; typedef signed char int8;
#if defined( _WIN32 ) #if defined(_WIN32)
typedef __int16 int16; typedef __int16 int16;
typedef unsigned __int16 uint16; typedef unsigned __int16 uint16;
@ -49,8 +49,8 @@ typedef int64 lint64;
typedef uint64 ulint64; typedef uint64 ulint64;
#ifdef X64BITS #ifdef X64BITS
typedef __int64 intp; // intp is an integer that can accomodate a pointer typedef __int64 intp; // intp is an integer that can accomodate a pointer
typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
#else #else
typedef __int32 intp; typedef __int32 intp;
typedef unsigned __int32 uintp; typedef unsigned __int32 uintp;
@ -85,29 +85,29 @@ typedef unsigned int uintp;
#endif // else _WIN32 #endif // else _WIN32
#ifdef API_GEN #ifdef API_GEN
# define STEAM_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR ))) #define STEAM_CLANG_ATTR(ATTR) __attribute__((annotate(ATTR)))
#else #else
# define STEAM_CLANG_ATTR(ATTR) #define STEAM_CLANG_ATTR(ATTR)
#endif #endif
#define STEAM_METHOD_DESC(DESC) STEAM_CLANG_ATTR( "desc:" #DESC ";" ) #define STEAM_METHOD_DESC(DESC) STEAM_CLANG_ATTR("desc:" #DESC ";")
#define STEAM_IGNOREATTR() STEAM_CLANG_ATTR( "ignore" ) #define STEAM_IGNOREATTR() STEAM_CLANG_ATTR("ignore")
#define STEAM_OUT_STRUCT() STEAM_CLANG_ATTR( "out_struct: ;" ) #define STEAM_OUT_STRUCT() STEAM_CLANG_ATTR("out_struct: ;")
#define STEAM_OUT_STRING() STEAM_CLANG_ATTR( "out_string: ;" ) #define STEAM_OUT_STRING() STEAM_CLANG_ATTR("out_string: ;")
#define STEAM_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) STEAM_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" ) #define STEAM_OUT_ARRAY_CALL(COUNTER, FUNCTION, PARAMS) STEAM_CLANG_ATTR("out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";")
#define STEAM_OUT_ARRAY_COUNT(COUNTER, DESC) STEAM_CLANG_ATTR( "out_array_count:" #COUNTER ";desc:" #DESC ) #define STEAM_OUT_ARRAY_COUNT(COUNTER, DESC) STEAM_CLANG_ATTR("out_array_count:" #COUNTER ";desc:" #DESC)
#define STEAM_ARRAY_COUNT(COUNTER) STEAM_CLANG_ATTR( "array_count:" #COUNTER ";" ) #define STEAM_ARRAY_COUNT(COUNTER) STEAM_CLANG_ATTR("array_count:" #COUNTER ";")
#define STEAM_ARRAY_COUNT_D(COUNTER, DESC) STEAM_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC ) #define STEAM_ARRAY_COUNT_D(COUNTER, DESC) STEAM_CLANG_ATTR("array_count:" #COUNTER ";desc:" #DESC)
#define STEAM_BUFFER_COUNT(COUNTER) STEAM_CLANG_ATTR( "buffer_count:" #COUNTER ";" ) #define STEAM_BUFFER_COUNT(COUNTER) STEAM_CLANG_ATTR("buffer_count:" #COUNTER ";")
#define STEAM_OUT_BUFFER_COUNT(COUNTER) STEAM_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" ) #define STEAM_OUT_BUFFER_COUNT(COUNTER) STEAM_CLANG_ATTR("out_buffer_count:" #COUNTER ";")
#define STEAM_OUT_STRING_COUNT(COUNTER) STEAM_CLANG_ATTR( "out_string_count:" #COUNTER ";" ) #define STEAM_OUT_STRING_COUNT(COUNTER) STEAM_CLANG_ATTR("out_string_count:" #COUNTER ";")
#define STEAM_DESC(DESC) STEAM_CLANG_ATTR("desc:" #DESC ";") #define STEAM_DESC(DESC) STEAM_CLANG_ATTR("desc:" #DESC ";")
#define STEAM_CALL_RESULT(RESULT_TYPE) STEAM_CLANG_ATTR("callresult:" #RESULT_TYPE ";") #define STEAM_CALL_RESULT(RESULT_TYPE) STEAM_CLANG_ATTR("callresult:" #RESULT_TYPE ";")
#define STEAM_CALL_BACK(RESULT_TYPE) STEAM_CLANG_ATTR("callback:" #RESULT_TYPE ";") #define STEAM_CALL_BACK(RESULT_TYPE) STEAM_CLANG_ATTR("callback:" #RESULT_TYPE ";")
#define STEAM_FLAT_NAME(NAME) STEAM_CLANG_ATTR("flat_name:" #NAME ";") #define STEAM_FLAT_NAME(NAME) STEAM_CLANG_ATTR("flat_name:" #NAME ";")
const int k_cubSaltSize = 8; const int k_cubSaltSize = 8;
typedef uint8 Salt_t[ k_cubSaltSize ]; typedef uint8 Salt_t[k_cubSaltSize];
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// GID (GlobalID) stuff // GID (GlobalID) stuff
@ -120,15 +120,15 @@ typedef uint64 GID_t;
const GID_t k_GIDNil = 0xffffffffffffffffull; const GID_t k_GIDNil = 0xffffffffffffffffull;
// For convenience, we define a number of types that are just new names for GIDs // For convenience, we define a number of types that are just new names for GIDs
typedef uint64 JobID_t; // Each Job has a unique ID typedef uint64 JobID_t; // Each Job has a unique ID
typedef GID_t TxnID_t; // Each financial transaction has a unique ID typedef GID_t TxnID_t; // Each financial transaction has a unique ID
const GID_t k_TxnIDNil = k_GIDNil; const GID_t k_TxnIDNil = k_GIDNil;
const GID_t k_TxnIDUnknown = 0; const GID_t k_TxnIDUnknown = 0;
const JobID_t k_JobIDNil = 0xffffffffffffffffull; const JobID_t k_JobIDNil = 0xffffffffffffffffull;
// this is baked into client messages and interfaces as an int, // this is baked into client messages and interfaces as an int,
// make sure we never break this. // make sure we never break this.
typedef uint32 PackageId_t; typedef uint32 PackageId_t;
const PackageId_t k_uPackageIdInvalid = 0xFFFFFFFF; const PackageId_t k_uPackageIdInvalid = 0xFFFFFFFF;
@ -136,7 +136,7 @@ const PackageId_t k_uPackageIdInvalid = 0xFFFFFFFF;
typedef uint32 BundleId_t; typedef uint32 BundleId_t;
const BundleId_t k_uBundleIdInvalid = 0; const BundleId_t k_uBundleIdInvalid = 0;
// this is baked into client messages and interfaces as an int, // this is baked into client messages and interfaces as an int,
// make sure we never break this. // make sure we never break this.
typedef uint32 AppId_t; typedef uint32 AppId_t;
const AppId_t k_uAppIdInvalid = 0x0; const AppId_t k_uAppIdInvalid = 0x0;
@ -147,8 +147,7 @@ const AssetClassId_t k_ulAssetClassIdInvalid = 0x0;
typedef uint32 PhysicalItemId_t; typedef uint32 PhysicalItemId_t;
const PhysicalItemId_t k_uPhysicalItemIdInvalid = 0x0; const PhysicalItemId_t k_uPhysicalItemIdInvalid = 0x0;
// this is baked into client messages and interfaces as an int,
// this is baked into client messages and interfaces as an int,
// make sure we never break this. AppIds and DepotIDs also presently // make sure we never break this. AppIds and DepotIDs also presently
// share the same namespace, but since we'd like to change that in the future // share the same namespace, but since we'd like to change that in the future
// I've defined it seperately here. // I've defined it seperately here.
@ -173,7 +172,7 @@ typedef uint32 PartnerId_t;
const PartnerId_t k_uPartnerIdInvalid = 0; const PartnerId_t k_uPartnerIdInvalid = 0;
// ID for a depot content manifest // ID for a depot content manifest
typedef uint64 ManifestId_t; typedef uint64 ManifestId_t;
const ManifestId_t k_uManifestIdInvalid = 0; const ManifestId_t k_uManifestIdInvalid = 0;
// ID for cafe sites // ID for cafe sites
@ -184,80 +183,74 @@ const SiteId_t k_ulSiteIdInvalid = 0;
typedef uint64 PartyBeaconID_t; typedef uint64 PartyBeaconID_t;
const PartyBeaconID_t k_ulPartyBeaconIdInvalid = 0; const PartyBeaconID_t k_ulPartyBeaconIdInvalid = 0;
enum ESteamIPType enum ESteamIPType {
{ k_ESteamIPTypeIPv4 = 0,
k_ESteamIPTypeIPv4 = 0, k_ESteamIPTypeIPv6 = 1,
k_ESteamIPTypeIPv6 = 1,
}; };
#pragma pack( push, 1 ) #pragma pack(push, 1)
struct SteamIPAddress_t struct SteamIPAddress_t {
{ union {
union {
uint32 m_unIPv4; // Host order uint32 m_unIPv4; // Host order
uint8 m_rgubIPv6[16]; // Network order! Same as inaddr_in6. (0011:2233:4455:6677:8899:aabb:ccdd:eeff) uint8 m_rgubIPv6[16]; // Network order! Same as inaddr_in6. (0011:2233:4455:6677:8899:aabb:ccdd:eeff)
// Internal use only // Internal use only
uint64 m_ipv6Qword[2]; // big endian uint64 m_ipv6Qword[2]; // big endian
}; };
ESteamIPType m_eType; ESteamIPType m_eType;
bool IsSet() const bool IsSet() const
{ {
if ( k_ESteamIPTypeIPv4 == m_eType ) if (k_ESteamIPTypeIPv4 == m_eType) {
{ return m_unIPv4 != 0;
return m_unIPv4 != 0; } else {
} return m_ipv6Qword[0] != 0 || m_ipv6Qword[1] != 0;
else }
{ }
return m_ipv6Qword[0] !=0 || m_ipv6Qword[1] != 0;
}
}
static SteamIPAddress_t IPv4Any() static SteamIPAddress_t IPv4Any()
{ {
SteamIPAddress_t ipOut; SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv4; ipOut.m_eType = k_ESteamIPTypeIPv4;
ipOut.m_unIPv4 = 0; ipOut.m_unIPv4 = 0;
return ipOut; return ipOut;
} }
static SteamIPAddress_t IPv6Any() static SteamIPAddress_t IPv6Any()
{ {
SteamIPAddress_t ipOut; SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv6; ipOut.m_eType = k_ESteamIPTypeIPv6;
ipOut.m_ipv6Qword[0] = 0; ipOut.m_ipv6Qword[0] = 0;
ipOut.m_ipv6Qword[1] = 0; ipOut.m_ipv6Qword[1] = 0;
return ipOut; return ipOut;
} }
static SteamIPAddress_t IPv4Loopback() static SteamIPAddress_t IPv4Loopback()
{ {
SteamIPAddress_t ipOut; SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv4; ipOut.m_eType = k_ESteamIPTypeIPv4;
ipOut.m_unIPv4 = 0x7f000001; ipOut.m_unIPv4 = 0x7f000001;
return ipOut; return ipOut;
} }
static SteamIPAddress_t IPv6Loopback() static SteamIPAddress_t IPv6Loopback()
{ {
SteamIPAddress_t ipOut; SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv6; ipOut.m_eType = k_ESteamIPTypeIPv6;
ipOut.m_ipv6Qword[0] = 0; ipOut.m_ipv6Qword[0] = 0;
ipOut.m_ipv6Qword[1] = 0; ipOut.m_ipv6Qword[1] = 0;
ipOut.m_rgubIPv6[15] = 1; ipOut.m_rgubIPv6[15] = 1;
return ipOut; return ipOut;
} }
}; };
#pragma pack( pop ) #pragma pack(pop)
#endif // STEAMTYPES_H #endif // STEAMTYPES_H

View File

@ -10,18 +10,15 @@
#pragma once #pragma once
#endif #endif
// Steam universes. Each universe is a self-contained Steam instance. // Steam universes. Each universe is a self-contained Steam instance.
enum EUniverse enum EUniverse {
{ k_EUniverseInvalid = 0,
k_EUniverseInvalid = 0, k_EUniversePublic = 1,
k_EUniversePublic = 1, k_EUniverseBeta = 2,
k_EUniverseBeta = 2, k_EUniverseInternal = 3,
k_EUniverseInternal = 3, k_EUniverseDev = 4,
k_EUniverseDev = 4, // k_EUniverseRC = 5, // no such universe anymore
// k_EUniverseRC = 5, // no such universe anymore k_EUniverseMax
k_EUniverseMax
}; };
#endif // STEAMUNIVERSE_H #endif // STEAMUNIVERSE_H

View File

@ -69,7 +69,6 @@ void SteamAccount::onAvatarImageLoaded(AvatarImageLoaded_t* avatarImage)
return; return;
} }
QImage avatar { QImage avatar {
imageData.data(), imageData.data(),
static_cast<int>(width), static_cast<int>(width),

View File

@ -24,5 +24,4 @@ bool setItemTags(const QVariant& updateHandle, const QStringList tags)
return SteamUGC()->SetItemTags(updateHandle.toULongLong(), pTags); return SteamUGC()->SetItemTags(updateHandle.toULongLong(), pTags);
} }
} }

View File

@ -17,8 +17,8 @@ struct ItemUpdateData {
QString m_preview; QString m_preview;
QMap<QString, QString> m_keyValueTag; //add new key-value tags for the item. Note that there can be multiple values for a tag. QMap<QString, QString> m_keyValueTag; //add new key-value tags for the item. Note that there can be multiple values for a tag.
QString m_changeNote; QString m_changeNote;
QPair<QString,ScreenPlayWorkshopSteamEnums::EItemPreviewType> m_previewFile; QPair<QString, ScreenPlayWorkshopSteamEnums::EItemPreviewType> m_previewFile;
QPair<QString,ScreenPlayWorkshopSteamEnums::EItemPreviewType> m_previewVideo; QPair<QString, ScreenPlayWorkshopSteamEnums::EItemPreviewType> m_previewVideo;
const char* title() const { return m_title.toUtf8().data(); } const char* title() const { return m_title.toUtf8().data(); }
const char* description() const { return m_description.toUtf8().data(); } const char* description() const { return m_description.toUtf8().data(); }

View File

@ -26,14 +26,15 @@ public:
SteamWorkshop* steamWorkshop() const { return m_steamWorkshop.get(); } SteamWorkshop* steamWorkshop() const { return m_steamWorkshop.get(); }
public slots: public slots:
void aaa(){ void aaa()
{
qDebug() << "aaaaaaaaaaaaaaaaaaaa"; qDebug() << "aaaaaaaaaaaaaaaaaaaa";
} }
bool init() bool init()
{ {
qInfo() << "steamWorkshop init"; qInfo() << "steamWorkshop init";
if(!steamWorkshop()){ if (!steamWorkshop()) {
qInfo() << "steamWorkshop NOT VALID!"; qInfo() << "steamWorkshop NOT VALID!";
} }