From 1a19a2cca1b7587f45f78accc96d2e5dfe9f4adc Mon Sep 17 00:00:00 2001 From: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com> Date: Fri, 9 Aug 2024 03:48:23 +0300 Subject: [PATCH] Update INetworkMessages, INetworkMessageInternal & CNetMessage After 8/8/2024 CS2 update --- public/networksystem/inetworkmessages.h | 7 ++----- public/networksystem/inetworkserializer.h | 2 -- public/networksystem/netmessage.h | 21 ++++++++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/public/networksystem/inetworkmessages.h b/public/networksystem/inetworkmessages.h index f6e94d38..ca86e741 100644 --- a/public/networksystem/inetworkmessages.h +++ b/public/networksystem/inetworkmessages.h @@ -71,13 +71,10 @@ public: virtual bool UnserializeMessageInternal( bf_read &pBuf, CNetMessage *pData ) = 0; virtual bool SerializeMessageInternal( bf_write &pBuf, const CNetMessage *pData ) = 0; + // Returns nullptr if failed to unserialize, reason is written to err_reason + virtual CNetMessage *UnserializeFromStream(bf_read &pBuf, CUtlString &err_reason) = 0; virtual bool SerializeAbstract(bf_write &pBuf, INetworkMessageInternal *pNetMessage, const CNetMessage *pData) = 0; - // Returns true if the buffer is fully read, false if there's still data left - virtual bool UnserializeAbstract(bf_read &pBuf, INetworkMessageInternal *pNetMessage, CNetMessage *pData) = 0; - virtual bool UnserializeAbstract(bf_read &pBuf, INetworkMessageInternal **pNetMessage, CNetMessage **pData) = 0; - - virtual CNetMessage *AllocateNetMessageAbstract(INetworkMessageInternal *pNetMessage) = 0; virtual CNetMessage *AllocateAndCopyConstructNetMessageAbstract(INetworkMessageInternal *pNetMessage, const CNetMessage *pFrom) = 0; virtual void DeallocateNetMessageAbstract(INetworkMessageInternal *pNetMessage, CNetMessage *pData) = 0; diff --git a/public/networksystem/inetworkserializer.h b/public/networksystem/inetworkserializer.h index c8ee8675..77ac43f8 100644 --- a/public/networksystem/inetworkserializer.h +++ b/public/networksystem/inetworkserializer.h @@ -66,8 +66,6 @@ public: virtual void SwitchMode( NetworkValidationMode_t nMode ) = 0; virtual CNetMessage *AllocateMessage() = 0; - virtual void DeallocateMessage( CNetMessage *pMsg ) = 0; - virtual CNetMessage *AllocateAndCopyConstructNetMessage( const CNetMessage *pOther ) = 0; // Calls to INetworkMessages::SerializeMessageInternal virtual bool Serialize( bf_write &pBuf, const CNetMessage *pData ) = 0; diff --git a/public/networksystem/netmessage.h b/public/networksystem/netmessage.h index 69f31aeb..f1e90d9e 100644 --- a/public/networksystem/netmessage.h +++ b/public/networksystem/netmessage.h @@ -13,18 +13,18 @@ class CNetMessagePB; class CNetMessage { public: + // Disabled as per CNetMessagePB note + CNetMessage() = delete; + CNetMessage( const CNetMessage & ) = delete; + virtual ~CNetMessage() {} // Returns the underlying proto object virtual void *AsProto() const = 0; virtual void *AsProto2() const = 0; - virtual INetworkMessageInternal *GetNetMessage() const - { - // This shouldn't ever be called and the game provided vtable should be called instead! - Assert(0); - return nullptr; - } + virtual INetworkMessageInternal *GetNetMessage() const = 0; + virtual CNetMessage *CopyConstruct( const CNetMessage *other ) const = 0; // Helper function to cast up the abstract message to a concrete CNetMessagePB type. // Doesn't do any validity checks itself! @@ -39,6 +39,9 @@ public: { return static_cast *>(this); } + +private: + char unk001[32]; }; // AMNOTE: This is a stub class over real CNetMessagePB! @@ -55,10 +58,10 @@ public: template class CNetMessagePB : public CNetMessage, public PROTO_TYPE { -private: +public: // Prevent manual construction of this object as per the comment above - CNetMessagePB() { }; - CNetMessagePB( const CNetMessagePB & ) { }; + CNetMessagePB() = delete; + CNetMessagePB( const CNetMessagePB & ) = delete; }; #endif // NETMESSAGE_H