void CLocalNetworkBackdoor::EntityDormant( int iEnt, int iSerialNum ) { CCachedEntState *pCached = &m_CachedEntState[iEnt]; IClientNetworkable *pNet = pCached->m_pNetworkable; Assert( pNet == entitylist->GetClientNetworkable( iEnt ) ); if ( pNet ) { Assert( pCached->m_iSerialNumber == pNet->GetIClientUnknown()->GetRefEHandle().GetSerialNumber() ); if ( pCached->m_iSerialNumber == iSerialNum ) { m_EntsAlive.Set( iEnt ); // Tell the game code that this guy is now dormant. Assert( pCached->m_bDormant == pNet->IsDormant() ); if ( !pCached->m_bDormant ) { pNet->NotifyShouldTransmit( SHOULDTRANSMIT_END ); pCached->m_bDormant = true; } } else { pNet->Release(); pCached->m_pNetworkable = NULL; m_PrevEntsAlive.Clear( iEnt ); } } }
void CLocalNetworkBackdoor::EndEntityStateUpdate() { ClientDLL_FrameStageNotify( FRAME_NET_UPDATE_POSTDATAUPDATE_START ); // Handle entities created. int i; for ( i=0; i < m_nEntsCreated; i++ ) { MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); int iEdict = m_EntsCreatedIndices[i]; CCachedEntState *pCached = &m_CachedEntState[iEdict]; IClientNetworkable *pNet = pCached->m_pNetworkable; pNet->PostDataUpdate( DATA_UPDATE_CREATED ); pNet->NotifyShouldTransmit( SHOULDTRANSMIT_START ); pCached->m_bDormant = false; } // Handle entities changed. for ( i=0; i < m_nEntsChanged; i++ ) { MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); int iEdict = m_EntsChangedIndices[i]; m_CachedEntState[iEdict].m_pNetworkable->PostDataUpdate( DATA_UPDATE_DATATABLE_CHANGED ); } ClientDLL_FrameStageNotify( FRAME_NET_UPDATE_POSTDATAUPDATE_END ); // Handle entities removed (= SV_WriteDeletions() in normal mode) int nDWords = m_PrevEntsAlive.GetNumDWords(); // Handle entities removed. for ( i=0; i < nDWords; i++ ) { unsigned long prevEntsAlive = m_PrevEntsAlive.GetDWord( i ); unsigned long entsAlive = m_EntsAlive.GetDWord( i ); unsigned long toDelete = (prevEntsAlive ^ entsAlive) & prevEntsAlive; if ( toDelete ) { for ( int iBit=0; iBit < 32; iBit++ ) { if ( toDelete & (1 << iBit) ) { int iEdict = (i<<5) + iBit; if ( iEdict < MAX_EDICTS ) { if ( m_CachedEntState[iEdict].m_pNetworkable ) { m_CachedEntState[iEdict].m_pNetworkable->Release(); m_CachedEntState[iEdict].m_pNetworkable = NULL; } else { AssertOnce( !"EndEntityStateUpdate: Would have crashed with NULL m_pNetworkable\n" ); } } else { AssertOnce( !"EndEntityStateUpdate: Would have crashed with entity out of range\n" ); } } } } } // Remember the previous state of which entities were around. m_PrevEntsAlive = m_EntsAlive; // end of all entity update activity ClientDLL_FrameStageNotify( FRAME_NET_UPDATE_END ); /* #ifdef _DEBUG for ( i=0; i <= highest_index; i++ ) { if ( !( m_EntsAlive[i>>5] & (1 << (i & 31)) ) ) Assert( !m_CachedEntState[i].m_pNetworkable ); if ( ( m_EntsAlive[i>>5] & (1 << (i & 31)) ) && ( m_EntsCreated[i>>5] & (1 << (i & 31)) ) ) { Assert( FindInList( m_EntsCreatedIndices, m_nEntsCreated, i ) ); } if ( (m_EntsAlive[i>>5] & (1 << (i & 31))) && !(m_EntsCreated[i>>5] & (1 << (i & 31))) && (m_EntsChanged[i>>5] & (1 << (i & 31))) ) { Assert( FindInList( m_EntsChangedIndices, m_nEntsChanged, i ) ); } } #endif */ }