ddnet/src/engine/client/steam.cpp

43 lines
604 B
C++
Raw Normal View History

2020-08-20 10:17:44 +00:00
#include <engine/steam.h>
#include <steam/steam_api_flat.h>
class CSteam : public ISteam
{
char m_aPlayerName[16];
2020-08-20 10:17:44 +00:00
public:
CSteam()
{
ISteamFriends *pSteamFriends = SteamAPI_SteamFriends_v017();
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()
{
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();
}