Use Client AuthString for CSteamID if available.
This commit is contained in:
+21
-1
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file extension.cpp
|
* @file extension.cpp
|
||||||
@@ -65,11 +66,30 @@ void SteamWorks::SDK_OnUnload()
|
|||||||
delete this->pSWGameData;
|
delete this->pSWGameData;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSteamID SteamWorks::CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
CSteamID SteamWorks::CreateCommonCSteamID(IGamePlayer *pPlayer, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
||||||
{
|
{
|
||||||
EUniverse universe = k_EUniversePublic;
|
EUniverse universe = k_EUniversePublic;
|
||||||
EAccountType type = k_EAccountTypeIndividual;
|
EAccountType type = k_EAccountTypeIndividual;
|
||||||
|
|
||||||
|
const char *pAuth = pPlayer->GetAuthString(false); /* We're not using this for Auth. */
|
||||||
|
if (pAuth == NULL || pAuth[0] == '\0' || strlen(pAuth) < 11 || pAuth[6] == 'I')
|
||||||
|
{
|
||||||
|
return this->CreateCommonCSteamID(pPlayer->GetSteamAccountID(false), params, universeplace, typeplace);
|
||||||
|
}
|
||||||
|
|
||||||
|
universe = static_cast<EUniverse>(atoi(&pAuth[6]));
|
||||||
|
if (universe == k_EUniverseInvalid)
|
||||||
|
{
|
||||||
|
universe = k_EUniversePublic; /* Legacy Engine shim. */
|
||||||
|
}
|
||||||
|
|
||||||
|
return CSteamID(pPlayer->GetSteamAccountID(false), universe, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSteamID SteamWorks::CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
||||||
|
{
|
||||||
|
EUniverse universe = k_EUniversePublic;
|
||||||
|
EAccountType type = k_EAccountTypeIndividual;
|
||||||
if (params[0] >= universeplace)
|
if (params[0] >= universeplace)
|
||||||
{
|
{
|
||||||
universe = static_cast<EUniverse>(params[universeplace]);
|
universe = static_cast<EUniverse>(params[universeplace]);
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ public:
|
|||||||
//public: /* IClientListener */
|
//public: /* IClientListener */
|
||||||
//virtual void OnClientDisconnecting(int client);
|
//virtual void OnClientDisconnecting(int client);
|
||||||
public:
|
public:
|
||||||
|
CSteamID CreateCommonCSteamID(IGamePlayer *pPlayer, const cell_t *params, unsigned char universeplace, unsigned char typeplace);
|
||||||
CSteamID CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace, unsigned char typeplace);
|
CSteamID CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace, unsigned char typeplace);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ static ISteamGameServer *GetGSPointer(void)
|
|||||||
return g_SteamWorks.pSWGameServer->GetGameServer();
|
return g_SteamWorks.pSWGameServer->GetGameServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CSteamID CreateCommonCSteamID(IGamePlayer *pPlayer, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
||||||
|
{
|
||||||
|
return g_SteamWorks.CreateCommonCSteamID(pPlayer, params, universeplace, typeplace);
|
||||||
|
}
|
||||||
|
|
||||||
static CSteamID CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
static CSteamID CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
||||||
{
|
{
|
||||||
return g_SteamWorks.CreateCommonCSteamID(authid, params, universeplace, typeplace);
|
return g_SteamWorks.CreateCommonCSteamID(authid, params, universeplace, typeplace);
|
||||||
@@ -171,7 +176,7 @@ static cell_t sm_UserHasLicenseForApp(IPluginContext *pContext, const cell_t *pa
|
|||||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSteamID checkid = CreateCommonCSteamID(pPlayer->GetSteamAccountID(false), params);
|
CSteamID checkid = CreateCommonCSteamID(pPlayer, params);
|
||||||
return pServer->UserHasLicenseForApp(checkid, params[2]);
|
return pServer->UserHasLicenseForApp(checkid, params[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ static ISteamGameServerStats *GetServerStatsPointer(void)
|
|||||||
return g_SteamWorks.pSWGameServer->GetServerStats();
|
return g_SteamWorks.pSWGameServer->GetServerStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CSteamID CreateCommonCSteamID(IGamePlayer *pPlayer, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
||||||
|
{
|
||||||
|
return g_SteamWorks.CreateCommonCSteamID(pPlayer, params, universeplace, typeplace);
|
||||||
|
}
|
||||||
|
|
||||||
static CSteamID CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
static CSteamID CreateCommonCSteamID(uint32_t authid, const cell_t *params, unsigned char universeplace = 2, unsigned char typeplace = 3)
|
||||||
{
|
{
|
||||||
return g_SteamWorks.CreateCommonCSteamID(authid, params, universeplace, typeplace);
|
return g_SteamWorks.CreateCommonCSteamID(authid, params, universeplace, typeplace);
|
||||||
@@ -63,7 +68,7 @@ static cell_t sm_RequestUserStats(IPluginContext *pContext, const cell_t *params
|
|||||||
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSteamID checkid = CreateCommonCSteamID(pPlayer->GetSteamAccountID(false), params);
|
CSteamID checkid = CreateCommonCSteamID(pPlayer, params);
|
||||||
return pStats->RequestUserStats(checkid) != k_uAPICallInvalid ? 1 : 0;
|
return pStats->RequestUserStats(checkid) != k_uAPICallInvalid ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +93,7 @@ static cell_t sm_GetStatCell(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
cell_t *pValue;
|
cell_t *pValue;
|
||||||
pContext->LocalToPhysAddr(params[3], &pValue);
|
pContext->LocalToPhysAddr(params[3], &pValue);
|
||||||
CSteamID checkid = CreateCommonCSteamID(pPlayer->GetSteamAccountID(false), params, 4, 5);
|
CSteamID checkid = CreateCommonCSteamID(pPlayer, params, 4, 5);
|
||||||
return pStats->GetUserStat(checkid, pName, pValue) ? 1 : 0;
|
return pStats->GetUserStat(checkid, pName, pValue) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +136,7 @@ static cell_t sm_GetStatFloat(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
cell_t *pValue;
|
cell_t *pValue;
|
||||||
pContext->LocalToPhysAddr(params[3], &pValue);
|
pContext->LocalToPhysAddr(params[3], &pValue);
|
||||||
CSteamID checkid = CreateCommonCSteamID(pPlayer->GetSteamAccountID(false), params, 4, 5);
|
CSteamID checkid = CreateCommonCSteamID(pPlayer, params, 4, 5);
|
||||||
|
|
||||||
float fValue;
|
float fValue;
|
||||||
bool bResult = pStats->GetUserStat(checkid, pName, &fValue);
|
bool bResult = pStats->GetUserStat(checkid, pName, &fValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user