Fixed: Steam latest client API changes
--HG-- branch : compatibility-develop
This commit is contained in:
parent
4514d1179b
commit
6927bb5849
1 changed files with 60 additions and 23 deletions
|
@ -29,11 +29,9 @@
|
||||||
// prototypes definitions for Steam API functions we'll call
|
// prototypes definitions for Steam API functions we'll call
|
||||||
typedef bool (__cdecl *SteamAPI_InitFuncPtr)();
|
typedef bool (__cdecl *SteamAPI_InitFuncPtr)();
|
||||||
typedef void (__cdecl *SteamAPI_ShutdownFuncPtr)();
|
typedef void (__cdecl *SteamAPI_ShutdownFuncPtr)();
|
||||||
typedef ISteamApps* (__cdecl *SteamAppsFuncPtr)();
|
typedef HSteamUser (__cdecl *SteamAPI_GetHSteamUserFuncPtr)();
|
||||||
typedef ISteamClient* (__cdecl *SteamClientFuncPtr)();
|
typedef HSteamPipe (__cdecl *SteamAPI_GetHSteamPipeFuncPtr)();
|
||||||
typedef ISteamFriends* (__cdecl *SteamFriendsFuncPtr)();
|
typedef void* (__cdecl *SteamInternal_CreateInterfaceFuncPtr)(const char *ver);
|
||||||
typedef ISteamUser* (__cdecl *SteamUserFuncPtr)();
|
|
||||||
typedef ISteamUtils* (__cdecl *SteamUtilsFuncPtr)();
|
|
||||||
typedef void (__cdecl *SteamAPI_RegisterCallbackFuncPtr)(class CCallbackBase *pCallback, int iCallback);
|
typedef void (__cdecl *SteamAPI_RegisterCallbackFuncPtr)(class CCallbackBase *pCallback, int iCallback);
|
||||||
typedef void (__cdecl *SteamAPI_UnregisterCallbackFuncPtr)(class CCallbackBase *pCallback);
|
typedef void (__cdecl *SteamAPI_UnregisterCallbackFuncPtr)(class CCallbackBase *pCallback);
|
||||||
typedef void (__cdecl *SteamAPI_RunCallbacksFuncPtr)();
|
typedef void (__cdecl *SteamAPI_RunCallbacksFuncPtr)();
|
||||||
|
@ -46,15 +44,22 @@ if (nl##symbol == NULL) return false
|
||||||
|
|
||||||
NL_DECLARE_SYMBOL(SteamAPI_Init);
|
NL_DECLARE_SYMBOL(SteamAPI_Init);
|
||||||
NL_DECLARE_SYMBOL(SteamAPI_Shutdown);
|
NL_DECLARE_SYMBOL(SteamAPI_Shutdown);
|
||||||
NL_DECLARE_SYMBOL(SteamApps);
|
|
||||||
NL_DECLARE_SYMBOL(SteamClient);
|
NL_DECLARE_SYMBOL(SteamAPI_GetHSteamUser);
|
||||||
NL_DECLARE_SYMBOL(SteamFriends);
|
NL_DECLARE_SYMBOL(SteamAPI_GetHSteamPipe);
|
||||||
NL_DECLARE_SYMBOL(SteamUser);
|
NL_DECLARE_SYMBOL(SteamInternal_CreateInterface);
|
||||||
NL_DECLARE_SYMBOL(SteamUtils);
|
|
||||||
NL_DECLARE_SYMBOL(SteamAPI_RegisterCallback);
|
NL_DECLARE_SYMBOL(SteamAPI_RegisterCallback);
|
||||||
NL_DECLARE_SYMBOL(SteamAPI_UnregisterCallback);
|
NL_DECLARE_SYMBOL(SteamAPI_UnregisterCallback);
|
||||||
NL_DECLARE_SYMBOL(SteamAPI_RunCallbacks);
|
NL_DECLARE_SYMBOL(SteamAPI_RunCallbacks);
|
||||||
|
|
||||||
|
// instances of classes
|
||||||
|
static ISteamClient *s_SteamClient = NULL;
|
||||||
|
static ISteamUser *s_SteamUser = NULL;
|
||||||
|
static ISteamApps *s_SteamApps = NULL;
|
||||||
|
static ISteamFriends *s_SteamFriends = NULL;
|
||||||
|
static ISteamUtils *s_SteamUtils = NULL;
|
||||||
|
|
||||||
// taken from steam_api.h, we needed to change it to use our dynamically loaded functions
|
// taken from steam_api.h, we needed to change it to use our dynamically loaded functions
|
||||||
|
|
||||||
// Declares a callback member function plus a helper member variable which
|
// Declares a callback member function plus a helper member variable which
|
||||||
|
@ -172,7 +177,7 @@ public:
|
||||||
bool waitTicket(uint32 ms)
|
bool waitTicket(uint32 ms)
|
||||||
{
|
{
|
||||||
// call Steam method
|
// call Steam method
|
||||||
_AuthSessionTicketHandle = nlSteamUser()->GetAuthSessionTicket(_AuthSessionTicketData, sizeof(_AuthSessionTicketData), &_AuthSessionTicketSize);
|
_AuthSessionTicketHandle = s_SteamUser->GetAuthSessionTicket(_AuthSessionTicketData, sizeof(_AuthSessionTicketData), &_AuthSessionTicketSize);
|
||||||
|
|
||||||
nldebug("GetAuthSessionTicket returned %u bytes, handle %u", _AuthSessionTicketSize, _AuthSessionTicketHandle);
|
nldebug("GetAuthSessionTicket returned %u bytes, handle %u", _AuthSessionTicketSize, _AuthSessionTicketHandle);
|
||||||
|
|
||||||
|
@ -338,24 +343,56 @@ bool CSteamClient::init()
|
||||||
_Initialized = true;
|
_Initialized = true;
|
||||||
|
|
||||||
// load more Steam functions
|
// load more Steam functions
|
||||||
NL_LOAD_SYMBOL(SteamApps);
|
NL_LOAD_SYMBOL(SteamAPI_GetHSteamUser);
|
||||||
NL_LOAD_SYMBOL(SteamClient);
|
NL_LOAD_SYMBOL(SteamAPI_GetHSteamPipe);
|
||||||
NL_LOAD_SYMBOL(SteamFriends);
|
NL_LOAD_SYMBOL(SteamInternal_CreateInterface);
|
||||||
NL_LOAD_SYMBOL(SteamUser);
|
|
||||||
NL_LOAD_SYMBOL(SteamUtils);
|
HSteamUser hSteamUser = nlSteamAPI_GetHSteamUser();
|
||||||
|
HSteamPipe hSteamPipe = nlSteamAPI_GetHSteamPipe();
|
||||||
|
|
||||||
|
if (!hSteamPipe)
|
||||||
|
{
|
||||||
|
nlwarning("Unable to get Steam pipe");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// instanciate all used Steam classes
|
||||||
|
s_SteamClient = (ISteamClient*)nlSteamInternal_CreateInterface(STEAMCLIENT_INTERFACE_VERSION);
|
||||||
|
if (!s_SteamClient)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
s_SteamUser = s_SteamClient->GetISteamUser(hSteamUser, hSteamPipe, STEAMUSER_INTERFACE_VERSION);
|
||||||
|
if (!s_SteamUser)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
s_SteamApps = s_SteamClient->GetISteamApps(hSteamUser, hSteamPipe, STEAMAPPS_INTERFACE_VERSION);
|
||||||
|
if (!s_SteamApps)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
s_SteamFriends = s_SteamClient->GetISteamFriends(hSteamUser, hSteamPipe, STEAMFRIENDS_INTERFACE_VERSION);
|
||||||
|
if (!s_SteamFriends)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
s_SteamUtils = s_SteamClient->GetISteamUtils(hSteamPipe, STEAMUTILS_INTERFACE_VERSION);
|
||||||
|
if (!s_SteamUtils)
|
||||||
|
return false;
|
||||||
|
|
||||||
// set warning messages hook
|
// set warning messages hook
|
||||||
nlSteamClient()->SetWarningMessageHook(SteamWarningMessageHook);
|
s_SteamClient->SetWarningMessageHook(SteamWarningMessageHook);
|
||||||
|
|
||||||
bool loggedOn = nlSteamUser()->BLoggedOn();
|
bool loggedOn = s_SteamUser->BLoggedOn();
|
||||||
const char *lang = nlSteamApps()->GetCurrentGameLanguage();
|
|
||||||
|
|
||||||
nlinfo("Steam AppID: %u", nlSteamUtils()->GetAppID());
|
nlinfo("Steam AppID: %u", s_SteamUtils->GetAppID());
|
||||||
nlinfo("Steam login: %s", nlSteamFriends()->GetPersonaName());
|
nlinfo("Steam login: %s", s_SteamFriends->GetPersonaName());
|
||||||
nlinfo("Steam user logged: %s", loggedOn ? "yes":"no");
|
nlinfo("Steam user logged: %s", loggedOn ? "yes":"no");
|
||||||
nlinfo("Steam language: %s", lang);
|
|
||||||
|
|
||||||
|
const char *lang = s_SteamApps->GetCurrentGameLanguage();
|
||||||
|
|
||||||
|
if (lang && strlen(lang) > 0)
|
||||||
|
{
|
||||||
|
nlinfo("Steam language: %s", lang);
|
||||||
NLMISC::CI18N::setSystemLanguageCode(lang);
|
NLMISC::CI18N::setSystemLanguageCode(lang);
|
||||||
|
}
|
||||||
|
|
||||||
// don't need to continue, if not connected
|
// don't need to continue, if not connected
|
||||||
if (!loggedOn) return false;
|
if (!loggedOn) return false;
|
||||||
|
|
Loading…
Reference in a new issue