diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index 8f93b96019..559fa23553 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -25,7 +25,6 @@ ly_add_target( AZ::AzCore AZ::AzFramework AZ::AzNetworking - Legacy::CryCommon PRIVATE Gem::EMotionFXStaticLib Gem::PhysX.Static @@ -144,6 +143,7 @@ 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 faa089b852..59446e9889 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace Multiplayer { @@ -35,21 +36,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 - CrySystemEventBus::Handler::BusConnect(); - } - MultiplayerEditorConnection::~MultiplayerEditorConnection() - { - CrySystemEventBus::Handler::BusDisconnect(); - } - - void MultiplayerEditorConnection::OnCrySystemInitialized(ISystem&, const SSystemInitParams&) - { + // Wait to activate the editor-server until LegacySystemInterfaceCreated so that the logging system is ready + // Automated testing listens for these logs 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(); + // If the settings registry is not available at this point, + // then something catastrophic has happened in the application startup. + // That should have been caught and messaged out earlier in startup. + if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) + { + AZ::ComponentApplicationLifecycle::RegisterHandler( + *settingsRegistry, m_componentApplicationLifecycleHandler, + [this](AZStd::string_view /*path*/, AZ::SettingsRegistryInterface::Type /*type*/) + { + ActivateDedicatedEditorServer(); + }, + "LegacySystemInterfaceCreated"); + } } } diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h index 4a304323e4..0c892c847f 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h @@ -8,10 +8,10 @@ #pragma once -#include #include #include #include +#include namespace AzNetworking { @@ -23,12 +23,10 @@ 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(); + ~MultiplayerEditorConnection() = default; bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerEditorPackets::EditorServerReadyForLevelData& packet); bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerEditorPackets::EditorServerLevelData& packet); @@ -42,11 +40,6 @@ 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; @@ -55,5 +48,6 @@ namespace Multiplayer AZStd::vector m_buffer; AZ::IO::ByteContainerStream> m_byteStream; mutable bool m_isActivated = false; + AZ::SettingsRegistryInterface::NotifyEventHandler m_componentApplicationLifecycleHandler; }; }