diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 249848d..dfb05ce 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -1514,6 +1514,10 @@ void SV_WriteSpawn(sizebuf_t *msg) host_client->connected = TRUE; host_client->fully_connected = FALSE; +#ifdef REHLDS_FIXES + g_GameClients[host_client - g_psvs.clients]->SetSpawnedOnce(true); +#endif // REHLDS_FIXES + NotifyDedicatedServerUI("UpdatePlayers"); } @@ -2400,6 +2404,10 @@ void EXT_FUNC SV_ConnectClient_internal(void) host_client->uploading = FALSE; host_client->fully_connected = FALSE; +#ifdef REHLDS_FIXES + g_GameClients[host_client - g_psvs.clients]->SetSpawnedOnce(false); +#endif // REHLDS_FIXES + bIsSecure = Steam_GSBSecure(); Netchan_OutOfBandPrint(NS_SERVER, adr, "%c %i \"%s\" %i %i", 66, host_client->userid, NET_AdrToString(host_client->netchan.remote_address), bIsSecure, build_number()); Log_Printf("\"%s<%i><%s><>\" connected, address \"%s\"\n", name, host_client->userid, SV_GetClientIDString(host_client), NET_AdrToString(host_client->netchan.remote_address)); @@ -4657,7 +4665,7 @@ void SV_UpdateToReliableMessages(void) //Fix for the "server failed to transmit file 'AY&SY..." bug //https://github.com/dreamstalker/rehlds/issues/38 #ifdef REHLDS_FIXES - if (!client->fakeclient && (client->active || client->connected)) + if (!client->fakeclient && (client->active || g_GameClients[i]->GetSpawnedOnce())) { if (!svReliableCompressed && g_psv.reliable_datagram.cursize + client->netchan.message.cursize < client->netchan.message.maxsize) { diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index a88ab3a..a9fff47 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -35,6 +35,7 @@ CGameClient::CGameClient(int id, client_t* cl) { m_Id = id; m_pClient = cl; + m_bSpawnedOnce = false; } int EXT_FUNC CGameClient::GetId() diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index a0d0f3e..23aff4f 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -52,6 +52,10 @@ private: client_t* m_pClient; CNetChan m_NetChan; + // added this field to handle a bug with hanging clients in scoreboard after a map change. + // we would also use the field client_t:connected, but actually can't because there is a bug in CS client when server sends TeamScore + // and client is not yet initialized ScoreBoard which leads to memory corruption in the client. + bool m_bSpawnedOnce; public: CGameClient(int id, client_t* cl); @@ -82,6 +86,10 @@ public: virtual bool GetLoopback(); virtual client_t* GetClient(); + +public: + bool GetSpawnedOnce() const { return m_bSpawnedOnce; } + void SetSpawnedOnce(bool spawned) { m_bSpawnedOnce = spawned; } }; class CRehldsServerStatic : public IRehldsServerStatic {