2020-08-20 10:17:44 +00:00
|
|
|
#include <engine/steam.h>
|
|
|
|
|
|
|
|
#include <steam/steam_api_flat.h>
|
|
|
|
|
|
|
|
class CSteam : public ISteam
|
|
|
|
{
|
2020-08-20 10:19:03 +00:00
|
|
|
char m_aPlayerName[16];
|
2020-08-20 10:17:44 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CSteam()
|
|
|
|
{
|
|
|
|
ISteamFriends *pSteamFriends = SteamAPI_SteamFriends_v017();
|
2020-08-20 10:19:03 +00:00
|
|
|
str_copy(m_aPlayerName, SteamAPI_ISteamFriends_GetPersonaName(pSteamFriends), sizeof(m_aPlayerName));
|
2020-08-20 10:17:44 +00:00
|
|
|
}
|
|
|
|
~CSteam()
|
|
|
|
{
|
|
|
|
SteamAPI_Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *GetPlayerName()
|
|
|
|
{
|
2020-08-20 10:19:03 +00:00
|
|
|
return m_aPlayerName;
|
2020-08-20 10:17:44 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSteamStub : public ISteam
|
|
|
|
{
|
|
|
|
const char *GetPlayerName()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ISteam *CreateSteam()
|
|
|
|
{
|
|
|
|
if(!SteamAPI_Init())
|
|
|
|
{
|
|
|
|
return new CSteamStub();
|
|
|
|
}
|
|
|
|
return new CSteam();
|
|
|
|
}
|