Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed May 13, 2024
1 parent 82a3d1d commit a761efa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions rehlds/common/quakedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

typedef int BOOL;

// The maximum user messages
#define MAX_USERMESSAGES 256

// user message
#define MAX_USER_MSG_DATA 192

Expand Down
5 changes: 3 additions & 2 deletions rehlds/engine/pr_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 7 additions & 1 deletion rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion rehlds/engine/usermsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit a761efa

Please sign in to comment.