From 33e2bb905b5afd68e6de68d24d0e1d6cd3f82db4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Feb 2016 13:24:08 +0100 Subject: [PATCH] Network/NetPacket: Add Get(Const)Data method Former-commit-id: 53f4f230b3e7baa65c79d97b21e192108b771312 --- include/Nazara/Network/NetPacket.hpp | 2 ++ include/Nazara/Network/NetPacket.inl | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Network/NetPacket.hpp b/include/Nazara/Network/NetPacket.hpp index f906a5431..1f950606b 100644 --- a/include/Nazara/Network/NetPacket.hpp +++ b/include/Nazara/Network/NetPacket.hpp @@ -28,6 +28,8 @@ namespace Nz NetPacket(NetPacket&&) = default; inline ~NetPacket(); + inline const UInt8* GetConstData() const; + inline UInt8* GetData() const; inline UInt16 GetNetCode() const; virtual void OnReceive(UInt16 netCode, const void* data, std::size_t size); diff --git a/include/Nazara/Network/NetPacket.inl b/include/Nazara/Network/NetPacket.inl index 23825966f..198354732 100644 --- a/include/Nazara/Network/NetPacket.inl +++ b/include/Nazara/Network/NetPacket.inl @@ -2,9 +2,10 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include +#include namespace Nz { @@ -28,6 +29,20 @@ namespace Nz FreeStream(); } + inline const UInt8* NetPacket::GetConstData() const + { + NazaraAssert(m_buffer, "Invalid buffer"); + + return m_buffer->GetConstBuffer(); + } + + inline UInt8* NetPacket::GetData() const + { + NazaraAssert(m_buffer, "Invalid buffer"); + + return m_buffer->GetBuffer(); + } + inline UInt16 NetPacket::GetNetCode() const { return m_netCode;