Permalink
Browse files

Check multiple engine sources for updated AuthIDs. (#552)

  • Loading branch information...
1 parent c5703db commit 111c95fea64391b9e48a2435a7ebb60955eba735 @KyleSanderson KyleSanderson committed Oct 14, 2016
Showing with 50 additions and 42 deletions.
  1. +48 −42 core/PlayerManager.cpp
  2. +2 −0 core/PlayerManager.h
@@ -2008,49 +2008,8 @@ void CPlayer::Connect()
void CPlayer::UpdateAuthIds()
{
- if (m_IsAuthorized)
- {
- return;
- }
-
- // First cache engine networkid
- const char *authstr = engine->GetPlayerNetworkIDString(m_pEdict);
- if (!authstr)
- {
- // engine doesn't have the client's auth string just yet, we can't do anything
- return;
- }
-
- if (m_AuthID.compare(authstr) == 0)
- {
+ if (m_IsAuthorized || (!SetEngineString() && !SetCSteamID()))
return;
- }
-
- m_AuthID = authstr;
-
- // Then, cache SteamId
- if (IsFakeClient())
- {
- m_SteamId = k_steamIDNil;
- }
- else
- {
-#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_SteamId = CSteamID(atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1),
- k_unSteamUserDesktopInstance, k_EUniversePublic, k_EAccountTypeIndividual);
- }
-#else
- const CSteamID *steamId = engine->GetClientSteamID(m_pEdict);
- if (steamId)
- {
- m_SteamId = (*steamId);
- }
-#endif
- }
// Now cache Steam2/3 rendered ids
if (IsFakeClient())
@@ -2102,6 +2061,53 @@ void CPlayer::UpdateAuthIds()
m_Steam3Id = szAuthBuffer;
}
+bool CPlayer::SetEngineString()
+{
+ const char *authstr = engine->GetPlayerNetworkIDString(m_pEdict);
+ if (!authstr || m_AuthID.compare(authstr) == 0)
+ return false;
+
+ m_AuthID = authstr;
+ SetCSteamID();
+ return true;
+}
+
+bool CPlayer::SetCSteamID()
+{
+ if (IsFakeClient())
+ {
+ m_SteamId = k_steamIDNil;
+ return true; /* This is the default value. There's a bug-out branch in the caller function. */
+ }
+
+#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] != '_')
+ {
+ CSteamID sid = CSteamID(atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1),
+ k_unSteamUserDesktopInstance, k_EUniversePublic, k_EAccountTypeIndividual);
+
+ if (m_SteamId != sid)
+ {
+ m_SteamId = sid;
+ return true;
+ }
+ }
+#else
+ const CSteamID *steamId = engine->GetClientSteamID(m_pEdict);
+ if (steamId)
+ {
+ if (m_SteamId != (*steamId))
+ {
+ m_SteamId = (*steamId);
+ return true;
+ }
+ }
+#endif
+ return false;
+}
+
// Ensure a valid AuthString is set before calling.
void CPlayer::Authorize()
{
@@ -120,6 +120,8 @@ class CPlayer : public IGamePlayer
void Authorize_Post();
void DoPostConnectAuthorization();
bool IsAuthStringValidated();
+ bool SetEngineString();
+ bool SetCSteamID();
private:
bool m_IsConnected;
bool m_IsInGame;

0 comments on commit 111c95f

Please sign in to comment.