2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Merge pull request #243 from theAsmodai/master

Advanced reconnect detection for crashed clients
This commit is contained in:
theAsmodai 2016-10-07 20:14:29 +03:00 committed by GitHub
commit 662a700f44

View File

@ -2306,7 +2306,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
{
client_t *client;
netadr_t adr;
int nClientSlot;
int nClientSlot = 0;
#ifdef REHLDS_FIXES
char userinfo[MAX_INFO_STRING];
#else
@ -2376,11 +2376,23 @@ void EXT_FUNC SV_ConnectClient_internal(void)
for (nClientSlot = 0; nClientSlot < g_psvs.maxclients; nClientSlot++)
{
client = &g_psvs.clients[nClientSlot];
#ifndef REHLDS_FIXES
if (NET_CompareAdr(adr, client->netchan.remote_address))
{
reconnect = TRUE;
break;
}
#else // REHLDS_FIXES
auto isTimedOut = [](client_t* cl)
{
return realtime - cl->netchan.last_received > 10.0;
};
if (NET_CompareBaseAdr(adr, client->netchan.remote_address) && (adr.port == client->netchan.remote_address.port || isTimedOut(client))) {
reconnect = TRUE;
break;
}
#endif // REHLDS_FIXES
}
}