diff --git a/rehlds/HLTV/Core/src/Server.cpp b/rehlds/HLTV/Core/src/Server.cpp index 965078b..05c0cf1 100644 --- a/rehlds/HLTV/Core/src/Server.cpp +++ b/rehlds/HLTV/Core/src/Server.cpp @@ -89,6 +89,7 @@ Server::svc_func_s Server::m_ClientFuncs[] { svc_resourcelocation, "svc_resourcelocation", &Server::ParseResourceLocation }, { svc_sendcvarvalue, "svc_sendcvarvalue", &Server::ParseSendCvarValue }, { svc_sendcvarvalue2, "svc_sendcvarvalue2", &Server::ParseSendCvarValue2 }, + { svc_exec, "svc_exec", &Server::ParseExec }, { svc_endoflist, "End of List", nullptr } }; @@ -377,7 +378,12 @@ void Server::ProcessMessage(unsigned int seqNr) break; } +// With `HLTV_FIXES` enabled meaning of `svc_startofusermessages` changed a bit: now it is an id of the first user message +#ifdef HLTV_FIXES + if (cmd >= svc_startofusermessages) +#else // HLTV_FIXES if (cmd > svc_startofusermessages) +#endif // HLTV_FIXES { if (!ParseUserMessage(cmd)) { break; @@ -2291,7 +2297,12 @@ void Server::Reset() char *Server::GetCmdName(int cmd) { static char description[64]; +// With `HLTV_FIXES` enabled meaning of `svc_startofusermessages` changed a bit: now it is an id of the first user message +#ifdef HLTV_FIXES + if (cmd >= svc_startofusermessages && m_World) +#else // HLTV_FIXES if (cmd > svc_startofusermessages && m_World) +#endif // HLTV_FIXES { UserMsg *usermsg = m_World->GetUserMsg(cmd); if (usermsg) @@ -2345,6 +2356,15 @@ void Server::ParseSendCvarValue2() char *name = m_Instream->ReadString(); } +void Server::ParseExec() +{ + bool execClassScript = m_Instream->ReadByte() != 0; + if (execClassScript) + { + int scriptId = m_Instream->ReadByte(); + } +} + void Server::ReceiveSignal(ISystemModule *module, unsigned int signal, void *data) { BaseSystemModule::ReceiveSignal(module, signal, data); diff --git a/rehlds/HLTV/Core/src/Server.h b/rehlds/HLTV/Core/src/Server.h index 25b2fec..c929fa8 100644 --- a/rehlds/HLTV/Core/src/Server.h +++ b/rehlds/HLTV/Core/src/Server.h @@ -216,6 +216,7 @@ public: void ParseResourceLocation(); void ParseSendCvarValue(); void ParseSendCvarValue2(); + void ParseExec(); protected: struct svc_func_s { diff --git a/rehlds/HLTV/common/net_internal.h b/rehlds/HLTV/common/net_internal.h index e2af351..5b3a8cd 100644 --- a/rehlds/HLTV/common/net_internal.h +++ b/rehlds/HLTV/common/net_internal.h @@ -159,10 +159,25 @@ enum svc_commands_e svc_resourcelocation, svc_sendcvarvalue, svc_sendcvarvalue2, - svc_startofusermessages = svc_sendcvarvalue2, + svc_exec, + svc_reserve60, + svc_reserve61, + svc_reserve62, + svc_reserve63, +// Let's just use an id of the first user message instead of the last svc_* +// This change doesn't make the parsing code forward-compatible with future svc_* additions, but error-reporting should be better +#ifdef HLTV_FIXES + svc_startofusermessages = svc_reserve63 + 1, +#else // HLTV_FIXES + svc_startofusermessages = svc_exec, +#endif // HLTV_FIXES svc_endoflist = 255, }; +#ifdef HLTV_FIXES +static_assert(svc_startofusermessages == 64, "svc_startofusermessages should be equal to 64 for backward and forward compatibility"); +#endif // HLTV_FIXES + enum clc_commands : byte { clc_bad, diff --git a/rehlds/engine/net.h b/rehlds/engine/net.h index b39e126..072ba33 100644 --- a/rehlds/engine/net.h +++ b/rehlds/engine/net.h @@ -208,10 +208,25 @@ typedef enum svc_commands_e svc_resourcelocation, svc_sendcvarvalue, svc_sendcvarvalue2, - svc_startofusermessages = svc_sendcvarvalue2, + svc_exec, + svc_reserve60, + svc_reserve61, + svc_reserve62, + svc_reserve63, +// Let's just use an id of the first user message instead of the last svc_* +// This change makes code in `PF_MessageEnd_I` forward-compatible with future svc_* additions +#ifdef REHLDS_FIXES + svc_startofusermessages = svc_reserve63 + 1, +#else // REHLDS_FIXES + svc_startofusermessages = svc_exec, +#endif // REHLDS_FIXES svc_endoflist = 255, } svc_commands_t; +#ifdef REHLDS_FIXES +static_assert(svc_startofusermessages == 64, "svc_startofusermessages should be equal to 64 for backward and forward compatibility"); +#endif // REHLDS_FIXES + typedef enum clc_commands_e { clc_bad, diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index b1ef97f..be18e51 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -2122,8 +2122,12 @@ void EXT_FUNC PF_MessageEnd_I(void) if (gMsgBuffer.flags & SIZEBUF_OVERFLOWED) Sys_Error("%s: called, but message buffer from .dll had overflowed\n", __func__); - +// With `REHLDS_FIXES` enabled meaning of `svc_startofusermessages` changed a bit: now it is an id of the first user message +#ifdef REHLDS_FIXES + if (gMsgType >= svc_startofusermessages) +#else // REHLDS_FIXES if (gMsgType > svc_startofusermessages) +#endif // REHLDS_FIXES { UserMsg* pUserMsg = sv_gpUserMsgs; while (pUserMsg && pUserMsg->iMsg != gMsgType) @@ -2164,7 +2168,12 @@ void EXT_FUNC PF_MessageEnd_I(void) if ((gMsgDest == MSG_BROADCAST && gMsgBuffer.cursize + pBuffer->cursize > pBuffer->maxsize) || !pBuffer->data) return; +// With `REHLDS_FIXES` enabled meaning of `svc_startofusermessages` changed a bit: now it is an id of the first user message +#ifdef REHLDS_FIXES + if (gMsgType >= svc_startofusermessages && (gMsgDest == MSG_ONE || gMsgDest == MSG_ONE_UNRELIABLE)) +#else // REHLDS_FIXES if (gMsgType > svc_startofusermessages && (gMsgDest == MSG_ONE || gMsgDest == MSG_ONE_UNRELIABLE)) +#endif // REHLDS_FIXES { int entnum = NUM_FOR_EDICT((const edict_t *)gMsgEntity); if (entnum < 1 || entnum > g_psvs.maxclients) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index f81c410..595b30c 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -105,7 +105,12 @@ qboolean allow_cheats; char *gNullString = ""; int SV_UPDATE_BACKUP = SINGLEPLAYER_BACKUP; int SV_UPDATE_MASK = (SINGLEPLAYER_BACKUP - 1); +// With `REHLDS_FIXES` enabled we can simply use `svc_startofusermessages` instead of the hard-coded constant +#ifdef REHLDS_FIXES +int giNextUserMsg = svc_startofusermessages; +#else // REHLDS_FIXES int giNextUserMsg = 64; +#endif // REHLDS_FIXES cvar_t sv_lan = { "sv_lan", "0", 0, 0.0f, NULL }; cvar_t sv_lan_rate = { "sv_lan_rate", "20000.0", 0, 0.0f, NULL };