diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index 559fa23553..8f93b96019 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -25,6 +25,7 @@ ly_add_target( AZ::AzCore AZ::AzFramework AZ::AzNetworking + Legacy::CryCommon PRIVATE Gem::EMotionFXStaticLib Gem::PhysX.Static @@ -143,7 +144,6 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) Include BUILD_DEPENDENCIES PRIVATE - Legacy::CryCommon Legacy::Editor.Headers AZ::AzCore AZ::AzFramework diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp index 3c3c4f0664..faa089b852 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace Multiplayer { @@ -34,9 +35,24 @@ namespace Multiplayer m_networkEditorInterface = AZ::Interface::Get()->CreateNetworkInterface( AZ::Name(MpEditorInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *this); m_networkEditorInterface->SetTimeoutMs(AZ::TimeMs{ 0 }); // Disable timeouts on this network interface - ActivateDedicatedEditorServer(); + CrySystemEventBus::Handler::BusConnect(); } + MultiplayerEditorConnection::~MultiplayerEditorConnection() + { + CrySystemEventBus::Handler::BusDisconnect(); + } + + void MultiplayerEditorConnection::OnCrySystemInitialized(ISystem&, const SSystemInitParams&) + { + if (editorsv_isDedicated) + { + // Wait to activate the editor-server until CrySystemInitialized so that the logging system is ready + // Automated testing listens for these logs + ActivateDedicatedEditorServer(); + } + } + void MultiplayerEditorConnection::ActivateDedicatedEditorServer() const { if (m_isActivated || !editorsv_isDedicated) diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h index f6510896fe..4a304323e4 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h @@ -8,12 +8,9 @@ #pragma once +#include #include - -#include -#include #include -#include #include namespace AzNetworking @@ -26,10 +23,12 @@ namespace Multiplayer //! MultiplayerEditorConnection is a connection listener to synchronize the Editor and a local server it launches class MultiplayerEditorConnection final : public AzNetworking::IConnectionListener + , public CrySystemEventBus::Handler + { public: MultiplayerEditorConnection(); - ~MultiplayerEditorConnection() = default; + ~MultiplayerEditorConnection(); bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerEditorPackets::EditorServerReadyForLevelData& packet); bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerEditorPackets::EditorServerLevelData& packet); @@ -43,6 +42,11 @@ namespace Multiplayer void OnPacketLost([[maybe_unused]]AzNetworking::IConnection* connection, [[maybe_unused]]AzNetworking::PacketId packetId) override {} void OnDisconnect([[maybe_unused]]AzNetworking::IConnection* connection, [[maybe_unused]]AzNetworking::DisconnectReason reason, [[maybe_unused]]AzNetworking::TerminationEndpoint endpoint) override {} //! @} + + //! CrySystemEvents interface + //! @{ + void OnCrySystemInitialized(ISystem&, const SSystemInitParams&) override; + //! @} private: void ActivateDedicatedEditorServer() const;