From b3ad7dc76bc740607c3124e2d8db9cec4ca631c8 Mon Sep 17 00:00:00 2001 From: asmodai Date: Wed, 5 Oct 2016 19:32:08 +0300 Subject: [PATCH] Advanced reconnect detection for crashed clients --- rehlds/engine/sv_main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 183509a..cb05ccc 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -2297,7 +2297,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 @@ -2367,11 +2367,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 } }