From 1c511d112dab8d2483718289a985d12b3eb422ae Mon Sep 17 00:00:00 2001 From: Damian Korczowski Date: Mon, 8 Mar 2021 23:42:33 +0100 Subject: [PATCH] Fix compilation & APIGen issues --- Source/Engine/Networking/INetworkDriver.h | 5 +++- Source/Engine/Networking/NetworkConfig.h | 1 + Source/Engine/Networking/NetworkConnection.h | 1 + Source/Engine/Networking/NetworkEvent.h | 1 + Source/Engine/Networking/NetworkManager.cpp | 5 ++-- Source/Engine/Networking/NetworkManager.h | 2 +- Source/Engine/Networking/NetworkMessage.h | 25 ++++++++++++-------- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Source/Engine/Networking/INetworkDriver.h b/Source/Engine/Networking/INetworkDriver.h index e5638c53e..749836d5a 100644 --- a/Source/Engine/Networking/INetworkDriver.h +++ b/Source/Engine/Networking/INetworkDriver.h @@ -2,8 +2,11 @@ #pragma once +#include "Engine/Scripting/ScriptingType.h" + API_INTERFACE() class FLAXENGINE_API INetworkDriver { +DECLARE_SCRIPTING_TYPE_MINIMAL(INetworkDriver); public: virtual void Initialize(const NetworkConfig& config) = 0; virtual void Dispose() = 0; @@ -13,7 +16,7 @@ public: virtual void Disconnect() = 0; virtual void Disconnect(const NetworkConnection& connection) = 0; - virtual bool PopEvent(NetworkEvent* event); + virtual bool PopEvent(NetworkEvent* eventPtr) = 0; virtual void SendMessage(NetworkChannelType channelType, const NetworkMessage& message, Array targets) = 0; diff --git a/Source/Engine/Networking/NetworkConfig.h b/Source/Engine/Networking/NetworkConfig.h index 3803c8ce8..64958fad9 100644 --- a/Source/Engine/Networking/NetworkConfig.h +++ b/Source/Engine/Networking/NetworkConfig.h @@ -4,6 +4,7 @@ API_STRUCT() struct FLAXENGINE_API NetworkConfig { +DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkConfig); public: INetworkDriver* NetworkDriver = nullptr; diff --git a/Source/Engine/Networking/NetworkConnection.h b/Source/Engine/Networking/NetworkConnection.h index 8feac0914..1c9170baf 100644 --- a/Source/Engine/Networking/NetworkConnection.h +++ b/Source/Engine/Networking/NetworkConnection.h @@ -6,6 +6,7 @@ API_STRUCT() struct FLAXENGINE_API NetworkConnection { +DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkConnection); public: uint32 ConnectionId; }; diff --git a/Source/Engine/Networking/NetworkEvent.h b/Source/Engine/Networking/NetworkEvent.h index cd3debba8..98f4ce7c0 100644 --- a/Source/Engine/Networking/NetworkEvent.h +++ b/Source/Engine/Networking/NetworkEvent.h @@ -17,6 +17,7 @@ API_ENUM() enum class NetworkEventType API_STRUCT() struct FLAXENGINE_API NetworkEvent { +DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkEvent); public: API_FIELD(); NetworkEventType EventType; diff --git a/Source/Engine/Networking/NetworkManager.cpp b/Source/Engine/Networking/NetworkManager.cpp index e9d619591..0463833c0 100644 --- a/Source/Engine/Networking/NetworkManager.cpp +++ b/Source/Engine/Networking/NetworkManager.cpp @@ -4,6 +4,7 @@ #include "NetworkMessage.h" #include "NetworkConfig.h" +#include "NetworkConnection.h" #include "INetworkDriver.h" #include "Engine/Core/Core.h" @@ -77,10 +78,10 @@ void NetworkManager::Disconnect(const NetworkConnection& connection) NetworkDriver->Disconnect(connection); } -bool NetworkManager::PopEvent(NetworkEvent* event) +bool NetworkManager::PopEvent(NetworkEvent* eventPtr) { ASSERT(NetworkDriver != nullptr); - return NetworkDriver->PopEvent(event); + return NetworkDriver->PopEvent(eventPtr); } NetworkMessage NetworkManager::BeginSendMessage() diff --git a/Source/Engine/Networking/NetworkManager.h b/Source/Engine/Networking/NetworkManager.h index dace276a8..25baf40f5 100644 --- a/Source/Engine/Networking/NetworkManager.h +++ b/Source/Engine/Networking/NetworkManager.h @@ -18,7 +18,7 @@ public: API_FUNCTION() static void Disconnect(); API_FUNCTION() static void Disconnect(const NetworkConnection& connection); - API_FUNCTION() static bool PopEvent(NetworkEvent* event); + API_FUNCTION() static bool PopEvent(NetworkEvent* eventPtr); API_FUNCTION() static NetworkMessage BeginSendMessage(); API_FUNCTION() static void AbortSendMessage(const NetworkMessage& message); diff --git a/Source/Engine/Networking/NetworkMessage.h b/Source/Engine/Networking/NetworkMessage.h index 1d0d34979..ce02caeea 100644 --- a/Source/Engine/Networking/NetworkMessage.h +++ b/Source/Engine/Networking/NetworkMessage.h @@ -6,37 +6,42 @@ API_STRUCT() struct FLAXENGINE_API NetworkMessage { +DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkMessage); public: API_FIELD() - uint8* Buffer; + uint8* Buffer = nullptr; API_FIELD() - uint32 MessageId; // TODO: Make it read-only + uint32 MessageId = 0; // TODO: Make it read-only API_FIELD() - uint32 BufferSize; + uint32 BufferSize = 0; API_FIELD() - uint32 Length; + uint32 Length = 0; API_FIELD() - uint32 Position; + uint32 Position = 0; public: + NetworkMessage() = default; + NetworkMessage(uint8* buffer, uint32 messageId, uint32 bufferSize, uint32 length, uint32 position) : Buffer(buffer), MessageId(messageId), BufferSize(bufferSize), Length(length), Position(position) { } + + ~NetworkMessage() = default; public: - API_FUNCTION() void WriteBytes(uint8* bytes, int numBytes); - API_FUNCTION() void ReadBytes(uint8* bytes, int numBytes); + void WriteBytes(uint8* bytes, int numBytes); + void ReadBytes(uint8* bytes, int numBytes); public: - API_FUNCTION() void WriteUInt32(uint32 value); // TODO: Macro the shit out of this - API_FUNCTION() uint32 ReadUInt32(); + void WriteUInt32(uint32 value); // TODO: Macro the shit out of this + uint32 ReadUInt32(); public: - API_FUNCTION() bool IsValid() const + bool IsValid() const { return Buffer != nullptr && BufferSize > 0; }