From a52b352bd96fdba3eccb9457abd8b86f19d30eca Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 14 Apr 2023 15:03:16 +0200 Subject: [PATCH] Add `NetworkManager::GetClient` by `uint32 clientId` --- Source/Engine/Networking/NetworkManager.cpp | 10 ++++++++++ Source/Engine/Networking/NetworkManager.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/Source/Engine/Networking/NetworkManager.cpp b/Source/Engine/Networking/NetworkManager.cpp index c2b6fd2da..88a104c3e 100644 --- a/Source/Engine/Networking/NetworkManager.cpp +++ b/Source/Engine/Networking/NetworkManager.cpp @@ -236,6 +236,16 @@ NetworkClient* NetworkManager::GetClient(const NetworkConnection& connection) return nullptr; } +NetworkClient* NetworkManager::GetClient(uint32 clientId) +{ + for (NetworkClient* client : Clients) + { + if (client->ClientId == clientId) + return client; + } + return nullptr; +} + bool NetworkManager::StartServer() { PROFILE_CPU(); diff --git a/Source/Engine/Networking/NetworkManager.h b/Source/Engine/Networking/NetworkManager.h index a634217c1..81d607a65 100644 --- a/Source/Engine/Networking/NetworkManager.h +++ b/Source/Engine/Networking/NetworkManager.h @@ -153,6 +153,13 @@ public: /// Found client or null. API_FUNCTION() static NetworkClient* GetClient(API_PARAM(Ref) const NetworkConnection& connection); + /// + /// Gets the network client with a given identifier. Returns null if failed to find it. + /// + /// Network client identifier (synchronized on all peers). + /// Found client or null. + API_FUNCTION() static NetworkClient* GetClient(uint32 clientId); + public: /// /// Starts the network in server mode. Returns true if failed (eg. invalid config).