additions
This commit is contained in:
@@ -239,6 +239,15 @@ void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
|
||||
}
|
||||
}
|
||||
break;
|
||||
case k_EMessage_EntityDeleted:
|
||||
C_BaseEntity **ppEntities = m_pEntities;
|
||||
for ( int i = 0; i < MAX_EDICTS; i++ )
|
||||
{
|
||||
if (ppEntities[i] == NULL)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ EngineConsts_t *g_pEngineConstants;
|
||||
IPhysics *g_pPhysics;
|
||||
IPhysicsWorld *g_pPhysicsWorld;
|
||||
|
||||
IKotUIManager *g_pKotUI;
|
||||
|
||||
CreateInterfaceFn GetEngineFactory()
|
||||
{
|
||||
return Sys_GetFactory("engine");
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "networkbase.h"
|
||||
#include "iphysics.h"
|
||||
#include "ihumandevice.h"
|
||||
#include "kotgui/kotgui.h"
|
||||
|
||||
class CEngineVars
|
||||
{
|
||||
@@ -39,6 +40,8 @@ extern EngineConsts_t *g_pEngineConstants;
|
||||
extern IPhysics *g_pPhysics;
|
||||
extern IPhysicsWorld *g_pPhysicsWorld;
|
||||
|
||||
extern IKotUIManager *g_pKotUI;
|
||||
|
||||
#define FUNNY_SECURE_PORT 27015
|
||||
#define FUNNY_QUERY_PORT 27016
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ enum EMessageType: uint32_t
|
||||
|
||||
k_EMessage_PlayerSetLocalEntity,
|
||||
k_EMessage_ResetEntities,
|
||||
k_EMessage_EntityDeleted,
|
||||
};
|
||||
|
||||
struct PlayerJoined_t
|
||||
@@ -53,6 +54,12 @@ struct EntityClass_t
|
||||
int8_t m_szEntityName[256];
|
||||
};
|
||||
|
||||
struct EntityDelete_t
|
||||
{
|
||||
EMessageType m_eType;
|
||||
CNetworkProtocolUInt32 m_uIndex;
|
||||
};
|
||||
|
||||
struct EntityDataSync_t
|
||||
{
|
||||
EMessageType m_eType;
|
||||
@@ -81,6 +88,7 @@ union PlayerPacket_t
|
||||
EntityClass_t m_entityClass;
|
||||
EntityDataSync_t m_entityData;
|
||||
SetLocalEntity_t m_setLocalEntity;
|
||||
EntityDelete_t m_deleteEntity;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user