From d6629eea2e2a9219a7fe5ec0887e087bc8a32881 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 24 Jun 2021 13:56:16 -0700 Subject: [PATCH] Fix order of ops issue in MP Session Termination --- Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 9c2fa2f828..afb963804a 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -219,7 +219,8 @@ namespace Multiplayer // Cleanup connections, fire events and uninitialize state auto visitor = [reason](IConnection& connection) { connection.Disconnect(reason, TerminationEndpoint::Local); }; m_networkInterface->GetConnectionSet().VisitConnections(visitor); - if (GetAgentType() == MultiplayerAgentType::DedicatedServer || GetAgentType() == MultiplayerAgentType::ClientServer) + MultiplayerAgentType agentType = GetAgentType(); + if (agentType == MultiplayerAgentType::DedicatedServer || agentType == MultiplayerAgentType::ClientServer) { m_networkInterface->StopListening(); m_shutdownEvent.Signal(m_networkInterface); @@ -227,7 +228,7 @@ namespace Multiplayer InitializeMultiplayer(MultiplayerAgentType::Uninitialized); // Signal session management, do this after uninitializing state - if (GetAgentType() == MultiplayerAgentType::DedicatedServer || GetAgentType() == MultiplayerAgentType::ClientServer) + if (agentType == MultiplayerAgentType::DedicatedServer || agentType == MultiplayerAgentType::ClientServer) { if (AZ::Interface::Get() != nullptr) {