mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-01 01:25:38 +03:00
Merge pull request #243 from theAsmodai/master
Advanced reconnect detection for crashed clients
This commit is contained in:
commit
662a700f44
@ -2306,7 +2306,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
|
|||||||
{
|
{
|
||||||
client_t *client;
|
client_t *client;
|
||||||
netadr_t adr;
|
netadr_t adr;
|
||||||
int nClientSlot;
|
int nClientSlot = 0;
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_FIXES
|
||||||
char userinfo[MAX_INFO_STRING];
|
char userinfo[MAX_INFO_STRING];
|
||||||
#else
|
#else
|
||||||
@ -2376,11 +2376,23 @@ void EXT_FUNC SV_ConnectClient_internal(void)
|
|||||||
for (nClientSlot = 0; nClientSlot < g_psvs.maxclients; nClientSlot++)
|
for (nClientSlot = 0; nClientSlot < g_psvs.maxclients; nClientSlot++)
|
||||||
{
|
{
|
||||||
client = &g_psvs.clients[nClientSlot];
|
client = &g_psvs.clients[nClientSlot];
|
||||||
|
#ifndef REHLDS_FIXES
|
||||||
if (NET_CompareAdr(adr, client->netchan.remote_address))
|
if (NET_CompareAdr(adr, client->netchan.remote_address))
|
||||||
{
|
{
|
||||||
reconnect = TRUE;
|
reconnect = TRUE;
|
||||||
break;
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user