mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-28 15:45:46 +03:00
Implement svc_exec
support in the engine and HLTV (#737)
* Added `svc_exec` to the list of svc commands in engine * Added `svc_exec` support to HLTV code * Made the engine code forward-compatible with future svc_* additions * Added reserved svc_* slots in the enumerations
This commit is contained in:
parent
7513e71d3b
commit
987ee51a6b
@ -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);
|
||||
|
@ -216,6 +216,7 @@ public:
|
||||
void ParseResourceLocation();
|
||||
void ParseSendCvarValue();
|
||||
void ParseSendCvarValue2();
|
||||
void ParseExec();
|
||||
|
||||
protected:
|
||||
struct svc_func_s {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user