From ffb4a3c4323f37c70d1c89694c226fbe3dd2dc51 Mon Sep 17 00:00:00 2001 From: pereslav Date: Thu, 8 Jul 2021 17:07:51 +0100 Subject: [PATCH] Fixed crash when non-net entities get activated Signed-off-by: pereslav --- .../ServerToClientReplicationWindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp index 9892cdc7e4..082d556d85 100644 --- a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp +++ b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp @@ -201,10 +201,11 @@ namespace Multiplayer void ServerToClientReplicationWindow::OnEntityActivated(AZ::Entity* entity) { - ConstNetworkEntityHandle entityHandle(entity, GetNetworkEntityTracker()); - NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent(); + NetBindComponent* netBindComponent = entity->FindComponent(); if (netBindComponent != nullptr) { + ConstNetworkEntityHandle entityHandle(netBindComponent, GetNetworkEntityTracker()); + if (netBindComponent->HasController()) { if (IFilterEntityManager* filter = GetMultiplayer()->GetFilterEntityManager()) @@ -233,10 +234,10 @@ namespace Multiplayer void ServerToClientReplicationWindow::OnEntityDeactivated(AZ::Entity* entity) { - ConstNetworkEntityHandle entityHandle(entity, GetNetworkEntityTracker()); - NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent(); + NetBindComponent* netBindComponent = entity->FindComponent(); if (netBindComponent != nullptr) { + ConstNetworkEntityHandle entityHandle(netBindComponent, GetNetworkEntityTracker()); m_replicationSet.erase(entityHandle); } }