From bfd50851f851714b81215f0cc39a794a979ff7f2 Mon Sep 17 00:00:00 2001 From: Damian Korczowski Date: Thu, 1 Jul 2021 19:46:01 +0200 Subject: [PATCH] Move implementation from NetworkMessage source file into header file --- Source/Engine/Networking/NetworkMessage.cpp | 22 --------------------- Source/Engine/Networking/NetworkMessage.h | 19 +++++++++++++++--- 2 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 Source/Engine/Networking/NetworkMessage.cpp diff --git a/Source/Engine/Networking/NetworkMessage.cpp b/Source/Engine/Networking/NetworkMessage.cpp deleted file mode 100644 index 0ec7b5702..000000000 --- a/Source/Engine/Networking/NetworkMessage.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. - -#include "NetworkMessage.h" - -void NetworkMessage::WriteBytes(uint8* bytes, const int numBytes) -{ - ASSERT(Position + numBytes < BufferSize); - Platform::MemoryCopy(Buffer + Position, bytes, numBytes); - Position += numBytes; -} - -void NetworkMessage::ReadBytes(uint8* bytes, const int numBytes) -{ - ASSERT(Position + numBytes < BufferSize); - Platform::MemoryCopy(bytes, Buffer + Position, numBytes); - Position += numBytes; -} - -bool NetworkMessage::IsValid() const -{ - return Buffer != nullptr && BufferSize > 0; -} diff --git a/Source/Engine/Networking/NetworkMessage.h b/Source/Engine/Networking/NetworkMessage.h index b9d39fb3f..e8196667d 100644 --- a/Source/Engine/Networking/NetworkMessage.h +++ b/Source/Engine/Networking/NetworkMessage.h @@ -67,7 +67,12 @@ public: /// /// The bytes that will be written. /// The amount of bytes to write from the bytes pointer. - FORCE_INLINE void WriteBytes(uint8* bytes, int numBytes); + FORCE_INLINE void WriteBytes(uint8* bytes, const int numBytes) + { + ASSERT(Position + numBytes < BufferSize); + Platform::MemoryCopy(Buffer + Position, bytes, numBytes); + Position += numBytes; + } /// /// Reads raw bytes from the message into the given byte array. @@ -77,7 +82,12 @@ public: /// Should be of the same length as length or longer. /// /// The minimal amount of bytes that the buffer contains. - FORCE_INLINE void ReadBytes(uint8* bytes, int numBytes); + FORCE_INLINE void ReadBytes(uint8* bytes, const int numBytes) + { + ASSERT(Position + numBytes < BufferSize); + Platform::MemoryCopy(bytes, Buffer + Position, numBytes); + Position += numBytes; + } #define DECL_READWRITE(type, name) \ FORCE_INLINE void Write##name(type value) { WriteBytes(reinterpret_cast(&value), sizeof(type)); } \ @@ -196,5 +206,8 @@ public: /// /// Returns true if the message is valid for reading or writing. /// - bool IsValid() const; + bool IsValid() const + { + return Buffer != nullptr && BufferSize > 0; + } };