2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-26 13:31:04 +03:00

Minor cleanup

This commit is contained in:
s1lentq 2024-05-13 18:48:35 +07:00
parent 82a3d1d084
commit a761efa75d
4 changed files with 17 additions and 4 deletions

View File

@ -29,6 +29,9 @@
typedef int BOOL;
// The maximum user messages
#define MAX_USERMESSAGES 256
// user message
#define MAX_USER_MSG_DATA 192

View File

@ -2124,7 +2124,7 @@ void EXT_FUNC PF_MessageBegin_I(int msg_dest, int msg_type, const float *pOrigin
if (msg_type == 0)
Sys_Error("%s: Tried to create a message with a bogus message type ( 0 )", __func__);
gMsgStarted = 1;
gMsgStarted = TRUE;
gMsgType = msg_type;
gMsgEntity = ed;
gMsgDest = msg_dest;
@ -2151,7 +2151,7 @@ void EXT_FUNC PF_MessageEnd_I(void)
qboolean MsgIsVarLength = 0;
if (!gMsgStarted)
Sys_Error("%s: called with no active message\n", __func__);
gMsgStarted = 0;
gMsgStarted = FALSE;
if (gMsgEntity && (gMsgEntity->v.flags & FL_FAKECLIENT))
return;
@ -2275,6 +2275,7 @@ void EXT_FUNC PF_WriteByte_I(int iValue)
{
if (!gMsgStarted)
Sys_Error("%s: called with no active message\n", __func__);
MSG_WriteByte(&gMsgBuffer, iValue);
}

View File

@ -6568,7 +6568,13 @@ void SV_ClearEntities(void)
}
int EXT_FUNC RegUserMsg(const char *pszName, int iSize)
{
if (giNextUserMsg > 255 || !pszName || Q_strlen(pszName) > 11 || iSize > 192)
if (giNextUserMsg >= MAX_USERMESSAGES)
return 0;
if (iSize > MAX_USER_MSG_DATA)
return 0;
if (!pszName || Q_strlen(pszName) >= MAX_USERMESSAGES_LENGTH - 1)
return 0;
UserMsg *pUserMsgs = sv_gpUserMsgs;

View File

@ -31,11 +31,14 @@
#include "maintypes.h"
#include "quakedef.h"
// The maximum length of a usermessage name in a network transmission
#define MAX_USERMESSAGES_LENGTH 16
typedef struct _UserMsg
{
int iMsg;
int iSize;
char szName[16];
char szName[MAX_USERMESSAGES_LENGTH];
struct _UserMsg *next;
pfnUserMsgHook pfn;
} UserMsg;