additions
This commit is contained in:
@@ -280,6 +280,29 @@ CBaseEntity **CEntitySystem::GetEntities()
|
||||
return m_pEntities;
|
||||
}
|
||||
|
||||
void CEntitySystem::DestroyEntityByIndex( uint32_t uIndex )
|
||||
{
|
||||
if ( uIndex >= MAX_EDICTS )
|
||||
return;
|
||||
if (m_pEntities[uIndex])
|
||||
{
|
||||
delete m_pEntities[uIndex];
|
||||
m_pEntities[uIndex] = 0;
|
||||
}
|
||||
|
||||
EntityDelete_t stClassSync = {
|
||||
k_EMessage_EntityDeleted,
|
||||
uIndex,
|
||||
};
|
||||
if (g_pCurrentConnection)
|
||||
g_pCurrentConnection->SendPacket({&stClassSync, sizeof(stClassSync), 0, PACKET_MUST_ARRIVE});
|
||||
}
|
||||
|
||||
void CEntitySystem::DestroyEntityByPtr( CBaseEntity *pEntity )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CEntitySystem::SetAllowedEntityForPlayer( uint64_t ullPlayer, CBaseEntity *pEntity )
|
||||
{
|
||||
if (pEntity)
|
||||
|
||||
@@ -27,6 +27,9 @@ public:
|
||||
virtual void Think( float fDelta );
|
||||
virtual CBaseEntity **GetEntities();
|
||||
|
||||
virtual void DestroyEntityByIndex( uint32_t uIndex );
|
||||
virtual void DestroyEntityByPtr( CBaseEntity *pEntity );
|
||||
|
||||
virtual void NetRecvPacket( NetPacket_t *pPacket );
|
||||
virtual void NetSendThink( INetworkBase *pBase );
|
||||
virtual void SetAllowedEntityForPlayer( uint64_t ullPlayer, CBaseEntity *pEntity );
|
||||
|
||||
@@ -79,6 +79,21 @@ uint32_t NET_ServerCallback( NetCallback_t *pCallback )
|
||||
g_pCurrentConnection->SendPacket({&stLocalEntity, sizeof(stLocalEntity), pCallback->m_ullUserConnection, PACKET_MUST_ARRIVE});
|
||||
return 1;
|
||||
}
|
||||
if (pCallback->m_eType == NET_DISCONNECTED)
|
||||
{
|
||||
V_printf("user %llu has disconnected, bye!\n", pCallback->m_ullUserID);
|
||||
|
||||
CBaseEntity **ppEntitites = EntitySystem()->GetEntities();
|
||||
for ( int i = 0; i < MAX_EDICTS; i++ )
|
||||
{
|
||||
if (ppEntitites[i] == NULL)
|
||||
continue;
|
||||
if (ppEntitites[i]->m_ullOwner != pCallback->m_ullUserConnection)
|
||||
continue;
|
||||
EntitySystem()->DestroyEntityByIndex(i);
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user