Change vscript net message header size to 4 bytes from 2 bytes

to reduce hash collisions
This commit is contained in:
samisalreadytaken 2022-12-27 16:00:08 +03:00
parent 53d6ae6848
commit f5837d068f
2 changed files with 3 additions and 4 deletions

View File

@ -1338,8 +1338,7 @@ static const char *HasNetMsgCollision( int hash, const char *ignore )
inline int CNetMsgScriptHelper::Hash( const char *key )
{
int hash = HashStringCaseless( key );
Assert( hash < (1 << SCRIPT_NETMSG_HEADER_BITS) );
int hash = CaselessStringHashFunctor()( key );
return hash;
}
@ -1923,7 +1922,7 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CNetMsgScriptHelper, "CNetMsg", SCRIPT_SINGLETON "N
DEFINE_SCRIPTFUNC( Receive, "Set custom network message callback" )
DEFINE_SCRIPTFUNC_NAMED( Receive, "Recieve", SCRIPT_HIDE ) // This was a typo until v6.3
#ifdef GAME_DLL
DEFINE_SCRIPTFUNC( Send, "Send a custom network message from the server to the client (max 252 bytes)" )
DEFINE_SCRIPTFUNC( Send, "Send a custom network message from the server to the client (max 251 bytes)" )
#else
DEFINE_SCRIPTFUNC( Send, "Send a custom network message from the client to the server (max 2044 bytes)" )
#endif

View File

@ -24,7 +24,7 @@ void RegisterScriptSingletons();
#endif
#define SCRIPT_NETMSG_QUEUE_BITS 3 // determines the number of custom messages client can write to a usercmd
#define SCRIPT_NETMSG_HEADER_BITS (sizeof(word) << 3)
#define SCRIPT_NETMSG_HEADER_BITS (sizeof(unsigned int) << 3)
#define SCRIPT_NETMSG_STRING_SIZE 512