Skip to content

Commit 111c95f

Browse files
committed
Check multiple engine sources for updated AuthIDs. (#552)
1 parent c5703db commit 111c95f

File tree

2 files changed

+50
-42
lines changed

2 files changed

+50
-42
lines changed

core/PlayerManager.cpp

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,49 +2008,8 @@ void CPlayer::Connect()
20082008

20092009
void CPlayer::UpdateAuthIds()
20102010
{
2011-
if (m_IsAuthorized)
2012-
{
2013-
return;
2014-
}
2015-
2016-
// First cache engine networkid
2017-
const char *authstr = engine->GetPlayerNetworkIDString(m_pEdict);
2018-
if (!authstr)
2019-
{
2020-
// engine doesn't have the client's auth string just yet, we can't do anything
2021-
return;
2022-
}
2023-
2024-
if (m_AuthID.compare(authstr) == 0)
2025-
{
2011+
if (m_IsAuthorized || (!SetEngineString() && !SetCSteamID()))
20262012
return;
2027-
}
2028-
2029-
m_AuthID = authstr;
2030-
2031-
// Then, cache SteamId
2032-
if (IsFakeClient())
2033-
{
2034-
m_SteamId = k_steamIDNil;
2035-
}
2036-
else
2037-
{
2038-
#if SOURCE_ENGINE < SE_ORANGEBOX
2039-
const char * pAuth = GetAuthString();
2040-
/* STEAM_0:1:123123 | STEAM_ID_LAN | STEAM_ID_PENDING */
2041-
if (pAuth && (strlen(pAuth) > 10) && pAuth[8] != '_')
2042-
{
2043-
m_SteamId = CSteamID(atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1),
2044-
k_unSteamUserDesktopInstance, k_EUniversePublic, k_EAccountTypeIndividual);
2045-
}
2046-
#else
2047-
const CSteamID *steamId = engine->GetClientSteamID(m_pEdict);
2048-
if (steamId)
2049-
{
2050-
m_SteamId = (*steamId);
2051-
}
2052-
#endif
2053-
}
20542013

20552014
// Now cache Steam2/3 rendered ids
20562015
if (IsFakeClient())
@@ -2102,6 +2061,53 @@ void CPlayer::UpdateAuthIds()
21022061
m_Steam3Id = szAuthBuffer;
21032062
}
21042063

2064+
bool CPlayer::SetEngineString()
2065+
{
2066+
const char *authstr = engine->GetPlayerNetworkIDString(m_pEdict);
2067+
if (!authstr || m_AuthID.compare(authstr) == 0)
2068+
return false;
2069+
2070+
m_AuthID = authstr;
2071+
SetCSteamID();
2072+
return true;
2073+
}
2074+
2075+
bool CPlayer::SetCSteamID()
2076+
{
2077+
if (IsFakeClient())
2078+
{
2079+
m_SteamId = k_steamIDNil;
2080+
return true; /* This is the default value. There's a bug-out branch in the caller function. */
2081+
}
2082+
2083+
#if SOURCE_ENGINE < SE_ORANGEBOX
2084+
const char *pAuth = GetAuthString();
2085+
/* STEAM_0:1:123123 | STEAM_ID_LAN | STEAM_ID_PENDING */
2086+
if (pAuth && (strlen(pAuth) > 10) && pAuth[8] != '_')
2087+
{
2088+
CSteamID sid = CSteamID(atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1),
2089+
k_unSteamUserDesktopInstance, k_EUniversePublic, k_EAccountTypeIndividual);
2090+
2091+
if (m_SteamId != sid)
2092+
{
2093+
m_SteamId = sid;
2094+
return true;
2095+
}
2096+
}
2097+
#else
2098+
const CSteamID *steamId = engine->GetClientSteamID(m_pEdict);
2099+
if (steamId)
2100+
{
2101+
if (m_SteamId != (*steamId))
2102+
{
2103+
m_SteamId = (*steamId);
2104+
return true;
2105+
}
2106+
}
2107+
#endif
2108+
return false;
2109+
}
2110+
21052111
// Ensure a valid AuthString is set before calling.
21062112
void CPlayer::Authorize()
21072113
{

core/PlayerManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class CPlayer : public IGamePlayer
120120
void Authorize_Post();
121121
void DoPostConnectAuthorization();
122122
bool IsAuthStringValidated();
123+
bool SetEngineString();
124+
bool SetCSteamID();
123125
private:
124126
bool m_IsConnected;
125127
bool m_IsInGame;

0 commit comments

Comments
 (0)