i am still keeping the log messages enabled for now. this extra begin auth session check should still work for nosteamers while being able to re-authenticate steam players with steam

This commit is contained in:
jenz 2026-02-15 18:37:52 +00:00
parent 00c4ee1521
commit 0b5306f689

View File

@ -190,7 +190,7 @@ EBeginAuthSessionResult Hook_BeginAuthSession(const void *pAuthTicket, int cbAut
{
if (!g_bSuppressBeginAuthSession)
{
g_pSM->LogMessage(myself, "inside Hook_ BeginAuthSession 1");
g_pSM->LogMessage(myself, "inside Hook_ BeginAuthSession 1. %s", steamID.Render());
RETURN_META_VALUE(MRES_IGNORED, k_EBeginAuthSessionResultOK);
}
g_bSuppressBeginAuthSession = false;
@ -200,11 +200,11 @@ EBeginAuthSessionResult Hook_BeginAuthSession(const void *pAuthTicket, int cbAut
&& g_lastcbAuthTicket == cbAuthTicket)
{
// Let the server know everything is fine
g_pSM->LogMessage(myself, "inside Hook_ BeginAuthSession 2");
g_pSM->LogMessage(myself, "inside Hook_ BeginAuthSession 2. %s", steamID.Render());
RETURN_META_VALUE(MRES_SUPERCEDE, k_EBeginAuthSessionResultOK);
}
g_pSM->LogMessage(myself, "inside Hook_ BeginAuthSession 3");
g_pSM->LogMessage(myself, "inside Hook_ BeginAuthSession 3. %s", steamID.Render());
RETURN_META_VALUE(MRES_IGNORED, k_EBeginAuthSessionResultDuplicateRequest);
}
@ -358,7 +358,7 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
if (g_ConnectClientStorage.retrieve(aSteamID, &Storage))
{
g_pSM->LogMessage(myself, "entered has clientstorage");
g_pSM->LogMessage(myself, "entered has clientstorage. %s", aSteamID);
ExistingSteamid = true;
g_ConnectClientStorage.remove(aSteamID);
if (!Storage.SteamAuthFailed)
@ -371,7 +371,7 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
// Don't want to leave the client waiting forever if something breaks in the async forward
if (Storage.iClientChallenge == iClientChallenge)
{
g_pSM->LogMessage(myself, "entered async retry");
g_pSM->LogMessage(myself, "entered async retry. %s", aSteamID);
AsyncWaiting = true;
//reject async nosteamers (althought this statement is not reached even as async nosteamers are rejected with invalid ticket)
@ -389,27 +389,30 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
else
{
//client did a manual retry,
g_pSM->LogMessage(myself, "entered manual retry");
g_pSM->LogMessage(myself, "entered manual retry. %s", aSteamID);
if (Storage.SteamAuthFailed)
{
//its a nosteamer so dont use the clientstorage ticket
//its a nosteamer. or a steam player who failed auth once so far. so dont use the clientstorage ticket
g_lastcbAuthTicket = cbTicket;
g_lastAuthTicket = pvTicket;
SkipEndAuthSession = true;
result = k_EBeginAuthSessionResultInvalidTicket;
g_pSM->LogMessage(myself, "manual retry with SteamAuthFailed before Begin Auth Session. %s", aSteamID);
//result = k_EBeginAuthSessionResultInvalidTicket;
result = g_pBeginAuthSession(steamGameServer, pvTicket, cbTicket, g_lastClientSteamID);
g_pSM->LogMessage(myself, "manual retry with SteamAuthFailed after Begin Auth Session. %s", aSteamID);
}
else
{
g_pSM->LogMessage(myself, "in client storage about to do new storage");
g_pSM->LogMessage(myself, "in client storage about to do new storage. %s", aSteamID);
//create a new client storage for the steamplayer.
Storage = ConnectClientStorage(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
//use the ticket from the new clientstorage.
g_lastcbAuthTicket = Storage.cbTicket;
g_lastAuthTicket = Storage.pvTicket;
g_pSM->LogMessage(myself, "in client storage about to do beginauthsession");
g_pSM->LogMessage(myself, "in client storage about to do beginauthsession. %s", aSteamID);
result = g_pBeginAuthSession(steamGameServer, Storage.pvTicket, Storage.cbTicket, g_lastClientSteamID);
g_pSM->LogMessage(myself, "in client storage after beginauthsession");
g_pSM->LogMessage(myself, "in client storage after beginauthsession. %s", aSteamID);
}
}
}
@ -423,19 +426,19 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
//however if the first connecting client instead is in k_OnClientPreConnectEx_Accept then the after following
//k_OnClientPreConnectEx_Reject will work fine. Ex_Accept is always used until the server is full, hence should Ex_Reject
//never be the first to connect on a new map.
g_pSM->LogMessage(myself, "without client storage about to do beginauth session");
g_pSM->LogMessage(myself, "without client storage about to do beginauth session. %s", aSteamID);
result = g_pBeginAuthSession(steamGameServer, pvTicket, cbTicket, g_lastClientSteamID);
g_pSM->LogMessage(myself, "without client storage after beginauth session");
g_pSM->LogMessage(myself, "without client storage after beginauth session. %s", aSteamID);
}
if (!SkipEndAuthSession)
{
g_pSM->LogMessage(myself, "about to do endAuthSession");
g_pSM->LogMessage(myself, "about to do endAuthSession. %s", aSteamID);
g_pEndAuthSession(steamGameServer, g_lastClientSteamID); //xen said engine might start its own authsession, so end ours here.
}
bool NoSteam = g_SvNoSteam.GetInt();
bool SteamAuthFailed = false;
//g_pSM->LogMessage(myself, "g_pBeginAuthSession result: %d", result);
g_pSM->LogMessage(myself, "g_pBeginAuthSession result: %d. %s", result, aSteamID);
if (result != k_EBeginAuthSessionResultOK)
{
@ -455,7 +458,7 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
// Reject NoSteam players
if(SteamAuthFailed)
{
g_pSM->LogMessage(myself, "about to do rejectconnection 1");
g_pSM->LogMessage(myself, "about to do rejectconnection 1. %s", aSteamID);
g_pRejectConnectionFunc((CBaseServer*)this, address, iClientChallenge, "Steam ID already in use.");
return NULL;
}
@ -463,12 +466,12 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
// Kick existing player
if(Storage.pClient)
{
g_pSM->LogMessage(myself, "about to do disconnect");
g_pSM->LogMessage(myself, "about to do disconnect. %s", aSteamID);
Storage.pClient->Disconnect("Same Steam ID connected.");
}
else
{
g_pSM->LogMessage(myself, "about to do rejectconnection 2");
g_pSM->LogMessage(myself, "about to do rejectconnection 2. %s", aSteamID);
g_pRejectConnectionFunc((CBaseServer*)this, address, iClientChallenge, "Please try again later.");
return NULL;
}
@ -527,12 +530,12 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
}
// k_OnClientPreConnectEx_Accept
g_pSM->LogMessage(myself, "about to do DETOUR_MEMBER_CALL");
g_pSM->LogMessage(myself, "about to do DETOUR_MEMBER_CALL. %s", aSteamID);
g_bSuppressBeginAuthSession = true;
auto client = DETOUR_MEMBER_CALL(CBaseServer__ConnectClient)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
//auto client = DETOUR_MEMBER_MCALL_ORIGINAL(CBaseServer__ConnectClient, this)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
g_bSuppressBeginAuthSession = false;
g_pSM->LogMessage(myself, "finished DETOUR_MEMBER_CALL");
g_pSM->LogMessage(myself, "finished DETOUR_MEMBER_CALL. %s", aSteamID);
Storage.pClient = client;
g_ConnectClientStorage.replace(aSteamID, Storage);
@ -543,10 +546,10 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
Response.m_SteamID = g_lastClientSteamID;
Response.m_eAuthSessionResponse = k_EAuthSessionResponseAuthTicketInvalid; //nosteamer monkeys
Response.m_OwnerSteamID = Response.m_SteamID;
g_pSM->LogMessage(myself, "about to do OnValidateAuthTicketResponse");
g_pSM->LogMessage(myself, "about to do OnValidateAuthTicketResponse. %s", aSteamID);
DETOUR_MEMBER_MCALL_CALLBACK(CSteam3Server__OnValidateAuthTicketResponse, g_pSteam3Server)(&Response);
}
g_pSM->LogMessage(myself, "MEMBER 9 end.");
g_pSM->LogMessage(myself, "MEMBER 9 end. %s", aSteamID);
return client;
}