core/PlayerManager.cpp
changeset 3825 ecd2382ca37e
parent 3819 d17aed3d46bf
child 3872 4c93f74cae51
     1.1 --- a/core/PlayerManager.cpp	Sat Mar 16 23:02:36 2013 -0400
     1.2 +++ b/core/PlayerManager.cpp	Sat Mar 16 23:12:40 2013 -0400
     1.3 @@ -923,8 +923,7 @@
     1.4  	const char *networkid_force;
     1.5  	if ((networkid_force = engine->GetClientConVarValue(client, "networkid_force")) && networkid_force[0] != '\0')
     1.6  	{
     1.7 -		unsigned long long *steamId = (unsigned long long *)engine->GetClientSteamID(pEntity);
     1.8 -		unsigned int accountId = steamId ? (*steamId & 0xFFFFFFFF) : 0;
     1.9 +		unsigned int accountId = pPlayer->GetSteamAccountID();
    1.10  		g_Logger.LogMessage("\"%s<%d><STEAM_1:%d:%d><>\" has bad networkid (id \"%s\") (ip \"%s\")",
    1.11  			new_name, pPlayer->GetUserId(), accountId & 1, accountId >> 1, networkid_force, pPlayer->GetIPAddress());
    1.12  
    1.13 @@ -1586,6 +1585,7 @@
    1.14  	m_bIsSourceTV = false;
    1.15  	m_bIsReplay = false;
    1.16  	m_Serial.value = -1;
    1.17 +	m_SteamAccountID = 0;
    1.18  }
    1.19  
    1.20  void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
    1.21 @@ -1665,6 +1665,7 @@
    1.22  	m_bIsSourceTV = false;
    1.23  	m_bIsReplay = false;
    1.24  	m_Serial.value = -1;
    1.25 +	m_SteamAccountID = 0;
    1.26  }
    1.27  
    1.28  void CPlayer::SetName(const char *name)
    1.29 @@ -1697,6 +1698,35 @@
    1.30  	return m_AuthID.c_str();
    1.31  }
    1.32  
    1.33 +unsigned int CPlayer::GetSteamAccountID(bool validated)
    1.34 +{
    1.35 +	if (IsFakeClient() || (validated && !IsAuthStringValidated()))
    1.36 +	{
    1.37 +		return 0;
    1.38 +	}
    1.39 +
    1.40 +	if (m_SteamAccountID != 0)
    1.41 +	{
    1.42 +		return m_SteamAccountID;
    1.43 +	}
    1.44 +
    1.45 +#if SOURCE_ENGINE < SE_ORANGEBOX
    1.46 +	const char * pAuth = GetAuthString();
    1.47 +	/* STEAM_0:1:123123 | STEAM_ID_LAN | STEAM_ID_PENDING */
    1.48 +	if (pAuth && (strlen(pAuth) > 10) && pAuth[8] != '_')
    1.49 +	{
    1.50 +		m_SteamAccountID = (atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1));
    1.51 +	}
    1.52 +#else
    1.53 +	unsigned long long *steamId = (unsigned long long *)engine->GetClientSteamID(m_pEdict);
    1.54 +	if (steamId)
    1.55 +	{
    1.56 +		m_SteamAccountID = (*steamId & 0xFFFFFFFF);
    1.57 +	}
    1.58 +#endif
    1.59 +	return m_SteamAccountID;
    1.60 +}
    1.61 +
    1.62  edict_t *CPlayer::GetEdict()
    1.63  {
    1.64  	return m_pEdict;