@@ -740,7 +740,11 @@ void CScriptGameEventListener::StopListeningForEvent()
740740#ifdef _DEBUG
741741 // Event listeners are iterated forwards in the game event manager,
742742 // removing while iterating will cause it to skip one listener.
743- // This could be prevented by writing a custom game event manager.
743+ //
744+ // Fix this in engine without altering any behaviour by
745+ // changing event exeuction order to tail->head,
746+ // changing listener removal to tail->head,
747+ // changing listener addition to head
744748 if ( m_nEventTick == gpGlobals->tickcount )
745749 {
746750 Warning (" CScriptGameEventListener stopped in the same frame it was fired. This will break other event listeners!\n " );
@@ -1749,8 +1753,8 @@ void CNetMsgScriptHelper::WriteEntity( HSCRIPT hEnt )
17491753{
17501754 SCRIPT_NETMSG_WRITE_FUNC
17511755 CBaseEntity *p = ToEnt (hEnt);
1752- int i = p ? p->entindex () : - 1 ;
1753- m_MsgOut.WriteSBitLong ( i, MAX_EDICT_BITS );
1756+ int i = p ? p->entindex () : 0 ;
1757+ m_MsgOut.WriteUBitLong ( i, MAX_EDICT_BITS );
17541758}
17551759
17561760void CNetMsgScriptHelper::WriteEHandle ( HSCRIPT hEnt )
@@ -1861,7 +1865,11 @@ bool CNetMsgScriptHelper::ReadBool()
18611865
18621866HSCRIPT CNetMsgScriptHelper::ReadEntity ()
18631867{
1864- int index = m_MsgIn_ ()ReadSBitLong ( MAX_EDICT_BITS );
1868+ int index = m_MsgIn_ ()ReadUBitLong ( MAX_EDICT_BITS );
1869+
1870+ if ( !index )
1871+ return NULL ;
1872+
18651873#ifdef GAME_DLL
18661874 edict_t *e = INDEXENT (index);
18671875 if ( e && !e->IsFree () )
0 commit comments