1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2026-10-10 20:03:08 +08:00

Replace INetworkMessageInternal with NetMessageInfo_t

This commit is contained in:
Pavel Djundik
2026-10-06 19:47:10 +03:00
committed by GAMMACASE
parent dd3fefa157
commit c53e893aef
6 changed files with 41 additions and 54 deletions
+7 -7
View File
@@ -22,26 +22,26 @@ class CUtlSlot;
abstract_class IGameEventSystem : public IAppSystem
{
public:
virtual void RegisterGameEvent( INetworkMessageInternal *pEvent ) = 0;
virtual void RegisterGameEvent( NetMessageInfo_t *pEvent ) = 0;
virtual void RegisterGameEventHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, INetworkMessageInternal *pEvent, int nPriority ) = 0;
virtual void UnregisterGameEventHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, INetworkMessageInternal *pEvent ) = 0;
virtual void RegisterGameEventHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, NetMessageInfo_t *pEvent, int nPriority ) = 0;
virtual void UnregisterGameEventHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, NetMessageInfo_t *pEvent ) = 0;
// Providing nSize has no effect and is unused.
virtual void PostEventAbstract_Local( CSplitScreenSlot nSlot, INetworkMessageInternal *pEvent, const CNetMessage *pData, unsigned long nSize ) = 0;
virtual void PostEventAbstract_Local( CSplitScreenSlot nSlot, NetMessageInfo_t *pEvent, const CNetMessage *pData, unsigned long nSize ) = 0;
// Providing nSlot as -1 would select 0nth slot.
// clients pointer is a masked uint64 value where (client index - 1) is mapped to each bit.
// Providing nClientCount as -1 and clients pointer as NULL would post event to all available clients.
// Providing nSize has no effect and is unused.
virtual void PostEventAbstract( CSplitScreenSlot nSlot, bool bLocalOnly, int nClientCount, const uint64 *clients,
INetworkMessageInternal *pEvent, const CNetMessage *pData, unsigned long nSize, NetChannelBufType_t bufType ) = 0;
NetMessageInfo_t *pEvent, const CNetMessage *pData, unsigned long nSize, NetChannelBufType_t bufType ) = 0;
virtual void PostEventAbstract( CSplitScreenSlot nSlot, bool bLocalOnly, IRecipientFilter *pFilter,
INetworkMessageInternal *pEvent, const CNetMessage *pData, unsigned long nSize ) = 0;
NetMessageInfo_t *pEvent, const CNetMessage *pData, unsigned long nSize ) = 0;
// Posts the event to all clients, even tho the function name tells otherwise
// Providing nSize has no effect and is unused.
virtual void PostEntityEventAbstract( const CBaseHandle &hndl, INetworkMessageInternal *pEvent, const CNetMessage *pData, unsigned long nSize, NetChannelBufType_t bufType ) = 0;
virtual void PostEntityEventAbstract( const CBaseHandle &hndl, NetMessageInfo_t *pEvent, const CNetMessage *pData, unsigned long nSize, NetChannelBufType_t bufType ) = 0;
virtual void ProcessQueuedEvents() = 0;
virtual CEntityIndex GetEventSource() const = 0;
+4 -4
View File
@@ -27,7 +27,7 @@ class INetChannel;
class INetChannelInfo;
class INetMessageBinder;
class INetworkMessageProcessingPreFilter;
class INetworkMessageInternal;
struct NetMessageInfo_t;
class INetMessageDispatcher;
class InstantReplayMessage_t;
class CUtlSlot;
@@ -119,8 +119,8 @@ public:
virtual void StartRegisteringMessageHandlers( void ) = 0;
virtual void FinishRegisteringMessageHandlers( void ) = 0;
virtual void RegisterNetMessageHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, int nParamCount, INetworkMessageInternal *pNetMessage, int nPriority ) = 0;
virtual void UnregisterNetMessageHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, INetworkMessageInternal *pNetMessage ) = 0;
virtual void RegisterNetMessageHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, int nParamCount, NetMessageInfo_t *pNetMessage, int nPriority ) = 0;
virtual void UnregisterNetMessageHandlerAbstract( CUtlSlot *nSlot, const CUtlAbstractDelegate &delegate, NetMessageInfo_t *pNetMessage ) = 0;
virtual int GetNumBitsWritten( NetChannelBufType_t bufferType ) const = 0;
virtual void SetDemoRecorder( IDemoRecorderBase *pDemoRecorder ) = 0;
@@ -132,7 +132,7 @@ public:
virtual void InstallMessageFilter( INetworkMessageProcessingPreFilter *pFilter ) = 0;
virtual void UninstallMessageFilter( INetworkMessageProcessingPreFilter *pFilter ) = 0;
virtual void PostReceivedNetMessage( INetworkMessageInternal *pNetMessage, const CNetMessage *pData, const NetChannelBufType_t *pBufType, int nBits, int nInSequenceNr ) = 0;
virtual void PostReceivedNetMessage( NetMessageInfo_t *pNetMessage, const CNetMessage *pData, const NetChannelBufType_t *pBufType, int nBits, int nInSequenceNr ) = 0;
virtual void InsertReplayMessage( InstantReplayMessage_t &msg ) = 0;
virtual bool HasQueuedNetMessages( int nMessageId ) const = 0;
+1 -1
View File
@@ -148,7 +148,7 @@ public:
virtual void unk302() = 0;
virtual void unk303() = 0;
virtual void BroadcastMessage( INetworkMessageInternal *pNetMessage, const CNetMessage *pData, IRecipientFilter *filter ) = 0;
virtual void BroadcastMessage( NetMessageInfo_t *pNetMessage, const CNetMessage *pData, IRecipientFilter *filter ) = 0;
virtual bool IsRecordingDemo() = 0;
virtual uint8 GetClientConnectionType( CPlayerSlot slot ) = 0;
+6 -6
View File
@@ -61,7 +61,7 @@ abstract_class INetworkMessages
public:
virtual void RegisterNetworkCategory(NetworkCategoryId nCategoryId, char const *szDebugName) = 0;
virtual void AssociateNetMessageWithChannelCategoryAbstract(INetworkMessageInternal *pNetMessage, NetworkCategoryId nCategoryId, bool) = 0;
virtual void AssociateNetMessageWithChannelCategoryAbstract(NetMessageInfo_t *pNetMessage, NetworkCategoryId nCategoryId, bool) = 0;
virtual bool Serialize(bf_write &pBuf, const CNetMessage *pData) = 0;
@@ -76,10 +76,10 @@ public:
virtual void *RegisterNetworkArrayFieldSerializer(char const *, NetworkSerializationMode_t, NetworkFieldSerializeBufferCB, NetworkFieldUnserializeBufferCB, NetworkFieldInfoCB,
NetworkFieldMetaInfoCB, NetworkFieldSerializeBufferCB, NetworkFieldUnserializeBufferCB) = 0;
virtual NetMessageInfo_t *GetNetMessageInfo(INetworkMessageInternal *pNetMessage) = 0;
virtual NetMessageInfo_t *GetNetMessageInfo(NetMessageInfo_t *pNetMessage) = 0;
virtual INetworkMessageInternal* FindNetworkMessage(char const *szName) = 0;
virtual INetworkMessageInternal* FindNetworkMessagePartial(char const *szPartialName) = 0;
virtual NetMessageInfo_t* FindNetworkMessage(char const *szName) = 0;
virtual NetMessageInfo_t* FindNetworkMessagePartial(char const *szPartialName) = 0;
virtual NetworkGroupId FindNetworkGroup(char const *szGroup, bool bCreateIfNotFound = false) = 0;
virtual int GetNetworkGroupCount() = 0;
@@ -95,7 +95,7 @@ public:
virtual void unk102() = 0;
// Passing nMessasgeId as -1 would auto-assign the id even if bCannotBeNetworked is false based on the message name hash.
virtual INetworkMessageInternal *FindOrCreateNetMessage(int nMessageId, CNetMessage *(*pfnAllocateMessage)(), int nGroup, NetChannelBufType_t nDefaultBufferType, bool, bool bCannotBeNetworked) = 0;
virtual NetMessageInfo_t *FindOrCreateNetMessage(int nMessageId, NetMessageAllocateFn pfnAllocateMessage, int nGroup, NetChannelBufType_t nDefaultBufferType, bool bOkayToRedispatch, bool bCannotBeNetworked) = 0;
// Doesn't support duplicated callbacks per field
virtual void RegisterNetworkFieldChangeCallbackInternal(char const *szFieldName, uint64, NetworkFieldChangedDelegateType_t fieldType, CUtlAbstractDelegate pCallback, NetworkFieldChangeCallbackPerformType_t cbPerformType, int unkflag ) = 0;
@@ -108,7 +108,7 @@ public:
virtual void RegisterFieldChangeCallbackPriority(int nPriority) = 0;
virtual INetworkMessageInternal *FindNetworkMessageById(int nMessageId) = 0;
virtual NetMessageInfo_t *FindNetworkMessageById(int nMessageId) = 0;
virtual void SetIsForServer(bool bIsForServer) = 0;
virtual bool GetIsForServer() = 0;
+19 -32
View File
@@ -40,48 +40,35 @@ enum NetworkSerializationMode_t
NET_SERIALIZATION_MODE_CLIENT = 0x1,
};
typedef uint16 NetworkMessageId;
typedef uint32 NetworkMessageId;
typedef uint8 NetworkGroupId;
typedef uint NetworkCategoryId;
typedef CNetMessage *( *NetMessageAllocateFn )();
struct NetMessageInfo_t
{
int m_nCategories;
IProtobufBinding *m_pBinding;
CUtlString m_szName;
NetMessageAllocateFn m_pfnAllocateMessage;
CUtlString m_szGroup;
NetworkMessageId m_MessageId;
NetworkGroupId m_GroupId;
// (1 << 0) - FLAG_RELIABLE
// (1 << 6) - FLAG_AUTOASSIGNEDID
// (1 << 7) - FLAG_UNK001
uint8 m_nFlags;
int m_unk001;
int m_nCategories;
int m_unk002;
bool m_bOkayToRedispatch;
};
NetworkGroupId m_GroupId;
uint8 m_nDefaultBufferType : 5;
uint8 m_bCannotBeNetworked : 1;
uint8 m_bOkayToRedispatch : 1;
uint8 m_unk001 : 1; // Set for messages registered without a group (CSVCMsg_PacketEntities), excludes them from per-group message stats
abstract_class INetworkMessageInternal
{
public:
virtual ~INetworkMessageInternal() = 0;
const char *GetUnscopedName() const { return m_szName.Get(); }
const char *GetGroupName() const { return m_szGroup.Get(); }
NetworkMessageId GetMessageId() const { return m_MessageId; }
int GetCategoryMask() const { return m_nCategories; }
NetworkGroupId GetGroupId() const { return m_GroupId; }
NetChannelBufType_t GetDefaultBufferType() const { return (NetChannelBufType_t)m_nDefaultBufferType; }
bool CannotBeNetworked() const { return m_bCannotBeNetworked; }
virtual const char *GetUnscopedName() = 0;
virtual NetMessageInfo_t *GetNetMessageInfo() = 0;
virtual void SetMessageId( unsigned short nMessageId ) = 0;
virtual void AddCategoryMask( int nMask, bool ) = 0;
virtual void SwitchMode( NetworkValidationMode_t nMode ) = 0;
virtual CNetMessage *AllocateMessage() = 0;
// Calls to INetworkMessages::SerializeMessageInternal
virtual bool Serialize( bf_write &pBuf, const CNetMessage *pData ) = 0;
// Calls to INetworkMessages::UnserializeMessageInternal
virtual bool Unserialize( bf_read &pBuf, CNetMessage *pData ) = 0;
CNetMessage *AllocateMessage() const { return m_pfnAllocateMessage(); }
};
struct NetworkRecipientsFilter_t
+4 -4
View File
@@ -23,7 +23,7 @@ public:
virtual void *AsProto() const = 0;
virtual void *AsProto2() const = 0;
virtual INetworkMessageInternal *GetNetMessage() const = 0;
virtual NetMessageInfo_t *GetNetMessage() const = 0;
virtual CNetMessage *CopyConstruct( const CNetMessage *other ) const = 0;
virtual NetworkMessageId GetMessageId() const = 0;
@@ -56,10 +56,10 @@ private:
// This is mainly to access the game constructed objects, and not for direct initialization of them
// since this misses the CNetMessage implementation which requires supplying other proto related info like
// proto binding object, proto msg id/group, etc.
// So to allocate the message yourself use INetworkMessageInternal::AllocateMessage() or INetworkMessages::AllocateNetMessageAbstract()
// functions instead of direct initialization (they both are equivalent)!
// So to allocate the message yourself use NetMessageInfo_t::AllocateMessage()
// instead of direct initialization!
// Example usage:
// CNetMessagePB<ProtoClass> *msg = INetworkMessageInternal::AllocateMessage()->ToPB<ProtoClass>();
// CNetMessagePB<ProtoClass> *msg = pNetMessageInfo->AllocateMessage()->ToPB<ProtoClass>();
// msg->field1( 2 );
// msg->field2( 3 );
// IGameEventSystem::PostEventAbstract( ..., msg, ... );