Fix Source Engine bug where fakeclients don't disconnect properly on mapchange.

This commit is contained in:
BotoX 2019-09-29 21:28:35 +02:00
parent 77604e3fcd
commit 91dac016f1
3 changed files with 41 additions and 2 deletions

View File

@ -148,7 +148,7 @@ class ExtensionConfig(object):
cxx.cflags += [ cxx.cflags += [
'-pipe', '-pipe',
'-fno-strict-aliasing', '-fno-strict-aliasing',
'-Wall', # '-Wall',
# '-Werror', # '-Werror',
'-Wno-unused', '-Wno-unused',
'-Wno-switch', '-Wno-switch',

View File

@ -296,6 +296,7 @@ bool BSecure()
CDetour *g_Detour_CBaseServer__ConnectClient = NULL; CDetour *g_Detour_CBaseServer__ConnectClient = NULL;
CDetour *g_Detour_CBaseServer__RejectConnection = NULL; CDetour *g_Detour_CBaseServer__RejectConnection = NULL;
CDetour *g_Detour_CBaseServer__CheckChallengeType = NULL; CDetour *g_Detour_CBaseServer__CheckChallengeType = NULL;
CDetour *g_Detour_CBaseServer__InactivateClients = NULL;
CDetour *g_Detour_CSteam3Server__OnValidateAuthTicketResponse = NULL; CDetour *g_Detour_CSteam3Server__OnValidateAuthTicketResponse = NULL;
class ConnectClientStorage class ConnectClientStorage
@ -550,6 +551,25 @@ DETOUR_DECL_MEMBER7(CBaseServer__CheckChallengeType, bool, CBaseClient *, pClien
return DETOUR_MEMBER_CALL(CBaseServer__CheckChallengeType)(pClient, nUserID, address, nAuthProtocol, pCookie, cbCookie, iClientChallenge); return DETOUR_MEMBER_CALL(CBaseServer__CheckChallengeType)(pClient, nUserID, address, nAuthProtocol, pCookie, cbCookie, iClientChallenge);
} }
DETOUR_DECL_MEMBER0(CBaseServer__InactivateClients, void)
{
for(int slot = 0; slot < iserver->GetClientCount(); slot++)
{
int client = slot + 1;
IClient *pClient = iserver->GetClient(slot);
if(!pClient)
continue;
// Disconnect all fake clients manually before the engine just nukes them.
if(pClient->IsFakeClient() && !pClient->IsHLTV())
{
pClient->Disconnect("");
}
}
return DETOUR_MEMBER_CALL(CBaseServer__InactivateClients)();
}
void UpdateQueryCache() void UpdateQueryCache()
{ {
CQueryCache::CInfo &info = g_QueryCache.info; CQueryCache::CInfo &info = g_QueryCache.info;
@ -850,6 +870,14 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late)
} }
g_Detour_CBaseServer__CheckChallengeType->EnableDetour(); g_Detour_CBaseServer__CheckChallengeType->EnableDetour();
g_Detour_CBaseServer__InactivateClients = DETOUR_CREATE_MEMBER(CBaseServer__InactivateClients, "CBaseServer__InactivateClients");
if(!g_Detour_CBaseServer__InactivateClients)
{
snprintf(error, maxlen, "Failed to detour CBaseServer__InactivateClients.\n");
return false;
}
g_Detour_CBaseServer__InactivateClients->EnableDetour();
g_Detour_CSteam3Server__OnValidateAuthTicketResponse = DETOUR_CREATE_MEMBER(CSteam3Server__OnValidateAuthTicketResponse, "CSteam3Server__OnValidateAuthTicketResponse"); g_Detour_CSteam3Server__OnValidateAuthTicketResponse = DETOUR_CREATE_MEMBER(CSteam3Server__OnValidateAuthTicketResponse, "CSteam3Server__OnValidateAuthTicketResponse");
if(!g_Detour_CSteam3Server__OnValidateAuthTicketResponse) if(!g_Detour_CSteam3Server__OnValidateAuthTicketResponse)
{ {
@ -905,6 +933,11 @@ void Connect::SDK_OnUnload()
g_Detour_CBaseServer__CheckChallengeType->Destroy(); g_Detour_CBaseServer__CheckChallengeType->Destroy();
g_Detour_CBaseServer__CheckChallengeType = NULL; g_Detour_CBaseServer__CheckChallengeType = NULL;
} }
if(g_Detour_CBaseServer__InactivateClients)
{
g_Detour_CBaseServer__InactivateClients->Destroy();
g_Detour_CBaseServer__InactivateClients = NULL;
}
if(g_Detour_CSteam3Server__OnValidateAuthTicketResponse) if(g_Detour_CSteam3Server__OnValidateAuthTicketResponse)
{ {
g_Detour_CSteam3Server__OnValidateAuthTicketResponse->Destroy(); g_Detour_CSteam3Server__OnValidateAuthTicketResponse->Destroy();
@ -1055,7 +1088,7 @@ void Connect::SDK_OnAllLoaded()
{ {
int client = slot + 1; int client = slot + 1;
IClient *pClient = iserver->GetClient(slot); IClient *pClient = iserver->GetClient(slot);
if(!pClient || !pClient->IsConnected()) if(!pClient)
continue; continue;
CQueryCache::CPlayer &player = g_QueryCache.players[client]; CQueryCache::CPlayer &player = g_QueryCache.players[client];

View File

@ -79,6 +79,12 @@
"linux" "@_ZN11CBaseServer14ValidChallengeER8netadr_si" "linux" "@_ZN11CBaseServer14ValidChallengeER8netadr_si"
} }
"CBaseServer__InactivateClients"
{
"library" "engine"
"linux" "@_ZN11CBaseServer17InactivateClientsEv"
}
"net_sockets" "net_sockets"
{ {
"library" "engine" "library" "engine"