Added GetSteamAccountID function to IPlayerHelpers and native for sp (bug 5548, r=asherkin).
This commit is contained in:
+32
-2
@@ -923,8 +923,7 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
|
||||
const char *networkid_force;
|
||||
if ((networkid_force = engine->GetClientConVarValue(client, "networkid_force")) && networkid_force[0] != '\0')
|
||||
{
|
||||
unsigned long long *steamId = (unsigned long long *)engine->GetClientSteamID(pEntity);
|
||||
unsigned int accountId = steamId ? (*steamId & 0xFFFFFFFF) : 0;
|
||||
unsigned int accountId = pPlayer->GetSteamAccountID();
|
||||
g_Logger.LogMessage("\"%s<%d><STEAM_1:%d:%d><>\" has bad networkid (id \"%s\") (ip \"%s\")",
|
||||
new_name, pPlayer->GetUserId(), accountId & 1, accountId >> 1, networkid_force, pPlayer->GetIPAddress());
|
||||
|
||||
@@ -1586,6 +1585,7 @@ CPlayer::CPlayer()
|
||||
m_bIsSourceTV = false;
|
||||
m_bIsReplay = false;
|
||||
m_Serial.value = -1;
|
||||
m_SteamAccountID = 0;
|
||||
}
|
||||
|
||||
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||
@@ -1665,6 +1665,7 @@ void CPlayer::Disconnect()
|
||||
m_bIsSourceTV = false;
|
||||
m_bIsReplay = false;
|
||||
m_Serial.value = -1;
|
||||
m_SteamAccountID = 0;
|
||||
}
|
||||
|
||||
void CPlayer::SetName(const char *name)
|
||||
@@ -1697,6 +1698,35 @@ const char *CPlayer::GetAuthString(bool validated)
|
||||
return m_AuthID.c_str();
|
||||
}
|
||||
|
||||
unsigned int CPlayer::GetSteamAccountID(bool validated)
|
||||
{
|
||||
if (IsFakeClient() || (validated && !IsAuthStringValidated()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_SteamAccountID != 0)
|
||||
{
|
||||
return m_SteamAccountID;
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE < SE_ORANGEBOX
|
||||
const char * pAuth = GetAuthString();
|
||||
/* STEAM_0:1:123123 | STEAM_ID_LAN | STEAM_ID_PENDING */
|
||||
if (pAuth && (strlen(pAuth) > 10) && pAuth[8] != '_')
|
||||
{
|
||||
m_SteamAccountID = (atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1));
|
||||
}
|
||||
#else
|
||||
unsigned long long *steamId = (unsigned long long *)engine->GetClientSteamID(m_pEdict);
|
||||
if (steamId)
|
||||
{
|
||||
m_SteamAccountID = (*steamId & 0xFFFFFFFF);
|
||||
}
|
||||
#endif
|
||||
return m_SteamAccountID;
|
||||
}
|
||||
|
||||
edict_t *CPlayer::GetEdict()
|
||||
{
|
||||
return m_pEdict;
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
const char *GetName();
|
||||
const char *GetIPAddress();
|
||||
const char *GetAuthString(bool validated = true);
|
||||
unsigned int GetSteamAccountID(bool validated = true);
|
||||
edict_t *GetEdict();
|
||||
bool IsInGame();
|
||||
bool WasCountedAsInGame();
|
||||
@@ -126,6 +127,7 @@ private:
|
||||
bool m_bIsSourceTV;
|
||||
bool m_bIsReplay;
|
||||
serial_t m_Serial;
|
||||
unsigned int m_SteamAccountID;
|
||||
};
|
||||
|
||||
class PlayerManager :
|
||||
|
||||
@@ -174,6 +174,23 @@ static cell_t sm_GetClientAuthStr(IPluginContext *pCtx, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetSteamAccountID(IPluginContext *pCtx, const cell_t *params)
|
||||
{
|
||||
int index = params[1];
|
||||
if ((index < 1) || (index > g_Players.GetMaxClients()))
|
||||
{
|
||||
return pCtx->ThrowNativeError("Client index %d is invalid", index);
|
||||
}
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
|
||||
if (!pPlayer->IsConnected())
|
||||
{
|
||||
return pCtx->ThrowNativeError("Client %d is not connected", index);
|
||||
}
|
||||
|
||||
return pPlayer->GetSteamAccountID(!!params[2]);
|
||||
}
|
||||
|
||||
static cell_t sm_IsClientConnected(IPluginContext *pCtx, const cell_t *params)
|
||||
{
|
||||
int index = params[1];
|
||||
@@ -1651,6 +1668,7 @@ REGISTER_NATIVES(playernatives)
|
||||
{"CanUserTarget", CanUserTarget},
|
||||
{"ChangeClientTeam", ChangeClientTeam},
|
||||
{"GetClientAuthString", sm_GetClientAuthStr},
|
||||
{"GetSteamAccountID", sm_GetSteamAccountID},
|
||||
{"GetClientCount", sm_GetClientCount},
|
||||
{"GetClientInfo", sm_GetClientInfo},
|
||||
{"GetClientIP", sm_GetClientIP},
|
||||
|
||||
Reference in New Issue
Block a user