From a8afbd7d2e2f5017b5f49bc858bf9cb7c1e2e7e1 Mon Sep 17 00:00:00 2001 From: WPMGPRoSToTeMa Date: Wed, 19 Oct 2016 13:20:17 +0300 Subject: [PATCH] Re-fixed hung players #103 and early TeamScore #113 bugs Global reliable net buffer is deprecated now --- rehlds/engine/host.cpp | 10 +++++++ rehlds/engine/host_cmd.cpp | 34 +++++++++++++++++++++++ rehlds/engine/pr_cmds.cpp | 55 ++++++++++++++++++++++++++------------ rehlds/engine/sv_main.cpp | 10 +++++++ 4 files changed, 92 insertions(+), 17 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 59fdf4f..b894394 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -525,7 +525,17 @@ void SV_DropClient_internal(client_t *cl, qboolean crash, const char *string) g_GameClients[cl - g_psvs.clients]->SetSpawnedOnce(false); #endif // REHLDS_FIXES +#ifdef REHLDS_FIXES + for (int i = 0; i < g_psvs.maxclients; i++) + { + if (!g_psvs.clients[i].connected) + continue; + + SV_FullClientUpdate(cl, &g_psvs.clients[i].netchan.message); + } +#else // REHLDS_FIXES SV_FullClientUpdate(cl, &g_psv.reliable_datagram); +#endif // REHLDS_FIXES NotifyDedicatedServerUI("UpdatePlayers"); } diff --git a/rehlds/engine/host_cmd.cpp b/rehlds/engine/host_cmd.cpp index 630cc3a..400367e 100644 --- a/rehlds/engine/host_cmd.cpp +++ b/rehlds/engine/host_cmd.cpp @@ -2638,8 +2638,20 @@ void Host_TogglePause_f(void) else SV_BroadcastPrintf("%s unpaused the game\n", &pr_strings[sv_player->v.netname]); + // TODO: send svc_setpause to client on spawn command +#ifdef REHLDS_FIXES + for (int i = 0; i < g_psvs.maxclients; i++) + { + if (!g_psvs.clients[i].connected) + continue; + + MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_setpause); + MSG_WriteByte(&g_psvs.clients[i].netchan.message, g_psv.paused); + } +#else // REHLDS_FIXES MSG_WriteByte(&g_psv.reliable_datagram, svc_setpause); MSG_WriteByte(&g_psv.reliable_datagram, g_psv.paused); +#endif // REHLDS_FIXES } void Host_Pause_f(void) @@ -2656,8 +2668,19 @@ void Host_Pause_f(void) return; g_psv.paused = TRUE; +#ifdef REHLDS_FIXES + for (int i = 0; i < g_psvs.maxclients; i++) + { + if (!g_psvs.clients[i].connected) + continue; + + MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_setpause); + MSG_WriteByte(&g_psvs.clients[i].netchan.message, g_psv.paused); + } +#else // REHLDS_FIXES MSG_WriteByte(&g_psv.reliable_datagram, svc_setpause); MSG_WriteByte(&g_psv.reliable_datagram, g_psv.paused); +#endif // REHLDS_FIXES } void Host_Unpause_f(void) @@ -2674,8 +2697,19 @@ void Host_Unpause_f(void) return; g_psv.paused = FALSE; +#ifdef REHLDS_FIXES + for (int i = 0; i < g_psvs.maxclients; i++) + { + if (!g_psvs.clients[i].connected) + continue; + + MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_setpause); + MSG_WriteByte(&g_psvs.clients[i].netchan.message, g_psv.paused); + } +#else // REHLDS_FIXES MSG_WriteByte(&g_psv.reliable_datagram, svc_setpause); MSG_WriteByte(&g_psv.reliable_datagram, g_psv.paused); +#endif // REHLDS_FIXES } void Host_Interp_f(void) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 769bf08..7e24280 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -2171,26 +2171,47 @@ void EXT_FUNC PF_MessageEnd_I(void) ); } } - - sizebuf_t * pBuffer = WriteDest_Parm(gMsgDest); - if ((!gMsgDest && gMsgBuffer.cursize + pBuffer->cursize > pBuffer->maxsize) || !pBuffer->data) - return; - - if (gMsgType > svc_startofusermessages && (gMsgDest == MSG_ONE || gMsgDest == MSG_ONE_UNRELIABLE)) +#ifdef REHLDS_FIXES + auto writer = [MsgIsVarLength] +#endif { - int entnum = NUM_FOR_EDICT((const edict_t *)gMsgEntity); - if (entnum < 1 || entnum > g_psvs.maxclients) - Host_Error("WriteDest_Parm: not a client"); - - client_t* client = &g_psvs.clients[entnum - 1]; - if (client->fakeclient || !client->hasusrmsgs || (!client->active && !client->spawned)) + sizebuf_t * pBuffer = WriteDest_Parm(gMsgDest); + if ((gMsgDest == MSG_BROADCAST && gMsgBuffer.cursize + pBuffer->cursize > pBuffer->maxsize) || !pBuffer->data) return; - } - MSG_WriteByte(pBuffer, gMsgType); - if (MsgIsVarLength) - MSG_WriteByte(pBuffer, gMsgBuffer.cursize); - MSG_WriteBuf(pBuffer, gMsgBuffer.cursize, gMsgBuffer.data); + if (gMsgType > svc_startofusermessages && (gMsgDest == MSG_ONE || gMsgDest == MSG_ONE_UNRELIABLE)) + { + int entnum = NUM_FOR_EDICT((const edict_t *)gMsgEntity); + if (entnum < 1 || entnum > g_psvs.maxclients) + Host_Error("WriteDest_Parm: not a client"); + + client_t* client = &g_psvs.clients[entnum - 1]; + if (client->fakeclient || !client->hasusrmsgs || (!client->active && !client->spawned)) + return; + } + + MSG_WriteByte(pBuffer, gMsgType); + if (MsgIsVarLength) + MSG_WriteByte(pBuffer, gMsgBuffer.cursize); + MSG_WriteBuf(pBuffer, gMsgBuffer.cursize, gMsgBuffer.data); + } +#ifdef REHLDS_FIXES + ; + + if (gMsgDest == MSG_ALL) { + gMsgDest = MSG_ONE; + for (int i = 0; i < g_psvs.maxclients; i++) { + gMsgEntity = g_psvs.clients[i].edict; + if (gMsgEntity == nullptr) + continue; + if (FBitSet(gMsgEntity->v.flags, FL_FAKECLIENT)) + continue; + writer(); + } + } else { + writer(); + } +#endif switch (gMsgDest) { diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index eac3915..449be9c 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4607,7 +4607,17 @@ void SV_UpdateUserInfo(client_t *pClient) pClient->sendinfo = FALSE; pClient->sendinfo_time = realtime + 1.0; SV_ExtractFromUserinfo(pClient); +#ifdef REHLDS_FIXES + for (int i = 0; i < g_psvs.maxclients; i++) + { + if (!g_psvs.clients[i].connected) + continue; + + SV_FullClientUpdate(pClient, &g_psvs.clients[i].netchan.message); + } +#else // REHLDS_FIXES SV_FullClientUpdate(pClient, &g_psv.reliable_datagram); +#endif // REHLDS_FIXES } void SV_UpdateToReliableMessages(void)