Fix CScriptNetMsgHelper::WriteEntity()

This commit is contained in:
samisalreadytaken 2022-10-14 18:23:33 +03:00
parent 4aeaaa46c7
commit 9bf1fb4cea

View File

@ -1749,8 +1749,8 @@ void CNetMsgScriptHelper::WriteEntity( HSCRIPT hEnt )
{ {
SCRIPT_NETMSG_WRITE_FUNC SCRIPT_NETMSG_WRITE_FUNC
CBaseEntity *p = ToEnt(hEnt); CBaseEntity *p = ToEnt(hEnt);
int i = p ? p->entindex() : -1; int i = p ? p->entindex() : 0;
m_MsgOut.WriteSBitLong( i, MAX_EDICT_BITS ); m_MsgOut.WriteUBitLong( i, MAX_EDICT_BITS );
} }
void CNetMsgScriptHelper::WriteEHandle( HSCRIPT hEnt ) void CNetMsgScriptHelper::WriteEHandle( HSCRIPT hEnt )
@ -1861,7 +1861,11 @@ bool CNetMsgScriptHelper::ReadBool()
HSCRIPT CNetMsgScriptHelper::ReadEntity() HSCRIPT CNetMsgScriptHelper::ReadEntity()
{ {
int index = m_MsgIn_()ReadSBitLong( MAX_EDICT_BITS ); int index = m_MsgIn_()ReadUBitLong( MAX_EDICT_BITS );
if ( !index )
return NULL;
#ifdef GAME_DLL #ifdef GAME_DLL
edict_t *e = INDEXENT(index); edict_t *e = INDEXENT(index);
if ( e && !e->IsFree() ) if ( e && !e->IsFree() )