From d600b1c9fd6659f79ef15fc3eba481b43b51f28c Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Tue, 30 Nov 2021 11:10:00 -0800 Subject: [PATCH 1/3] Adding GetBool method to CmdLineArg Signed-off-by: Gene Walters --- Code/Legacy/CryCommon/ICmdLine.h | 8 ++++++++ Code/Legacy/CrySystem/CmdLineArg.cpp | 17 +++++++++++++++++ Code/Legacy/CrySystem/CmdLineArg.h | 1 + 3 files changed, 26 insertions(+) diff --git a/Code/Legacy/CryCommon/ICmdLine.h b/Code/Legacy/CryCommon/ICmdLine.h index 6071671b02..80561fd85c 100644 --- a/Code/Legacy/CryCommon/ICmdLine.h +++ b/Code/Legacy/CryCommon/ICmdLine.h @@ -71,6 +71,14 @@ public: // The value of the argument as integer number. virtual const int GetIValue() const = 0; // + + // Description: + // Retrieve the value of the argument. + // Arguments: + // cmdLineValue. The cmdline value will be filled out if a valid boolean is found. + // Return Value: + // Returns true if the cmdline arg is actually a boolean string matching "true" or "false"; otherwise return false. + virtual const bool GetBoolValue(bool& cmdLineValue) const = 0; }; // Command line interface diff --git a/Code/Legacy/CrySystem/CmdLineArg.cpp b/Code/Legacy/CrySystem/CmdLineArg.cpp index 79d23ddae7..554e734055 100644 --- a/Code/Legacy/CrySystem/CmdLineArg.cpp +++ b/Code/Legacy/CrySystem/CmdLineArg.cpp @@ -42,5 +42,22 @@ const int CCmdLineArg::GetIValue() const { return atoi(m_value.c_str()); } +const bool CCmdLineArg::GetBoolValue(bool& cmdLineValue) const +{ + AZStd::string lowercaseValue(m_value); + AZStd::to_lower(lowercaseValue.begin(), lowercaseValue.end()); + if (lowercaseValue == "true") + { + cmdLineValue = true; + return true; + } + if (lowercaseValue == "false") + { + cmdLineValue = false; + return true; + } + + return false; +} diff --git a/Code/Legacy/CrySystem/CmdLineArg.h b/Code/Legacy/CrySystem/CmdLineArg.h index 5e3a629e7c..66d56be132 100644 --- a/Code/Legacy/CrySystem/CmdLineArg.h +++ b/Code/Legacy/CrySystem/CmdLineArg.h @@ -30,6 +30,7 @@ public: const ECmdLineArgType GetType() const; const float GetFValue() const; const int GetIValue() const; + const bool GetBoolValue(bool& cmdLineValue) const; private: From 6d0ba68b55378c8170c72b4f2630cc1fcc902ebc Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Tue, 30 Nov 2021 11:12:07 -0800 Subject: [PATCH 2/3] Using new GetBool value when checking if we're an editor-server. Clean up MPEditorSystemComponent for unused #includes, and null-checking when piping server logs Signed-off-by: Gene Walters --- Code/Legacy/CrySystem/SystemInit.cpp | 5 ++--- .../Editor/MultiplayerEditorSystemComponent.cpp | 16 +++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Code/Legacy/CrySystem/SystemInit.cpp b/Code/Legacy/CrySystem/SystemInit.cpp index 6f550fcac6..70595e53c1 100644 --- a/Code/Legacy/CrySystem/SystemInit.cpp +++ b/Code/Legacy/CrySystem/SystemInit.cpp @@ -741,9 +741,8 @@ bool CSystem::Init(const SSystemInitParams& startupParams) bool suppressSystemOutput = true; if (const ICmdLineArg* isEditorServerArg = m_pCmdLine->FindArg(eCLAT_Pre, "editorsv_isDedicated")) { - AZ::CVarFixedString lowercaseValue(isEditorServerArg->GetValue()); - AZStd::to_lower(lowercaseValue.begin(), lowercaseValue.end()); - if (lowercaseValue == "true") + bool editorsv_isDedicated = false; + if (isEditorServerArg->GetBoolValue(editorsv_isDedicated) && editorsv_isDedicated) { suppressSystemOutput = false; } diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp index fa855cf28c..259d544279 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp @@ -6,7 +6,6 @@ * */ -#include "AzFramework/Process/ProcessCommunicator.h" #include #include @@ -16,11 +15,8 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -425,7 +421,17 @@ namespace Multiplayer void MultiplayerEditorSystemComponent::OnTick(float, AZ::ScriptTimePoint) { - m_serverProcessTracePrinter->Pump(); + if (m_serverProcessTracePrinter) + { + m_serverProcessTracePrinter->Pump(); + } + else + { + AZ::TickBus::Handler::BusDisconnect(); + AZ_Warning( + "MultiplayerEditorSystemComponent", false, + "The server process trace printer is NULL so we won't be able to pipe server logs to the editor. Please update the code to call AZ::TickBus::Handler::BusDisconnect whenever the editor-server is terminated.") + } } } From 8afd47950c788dfe5f6e317f3265fcef3a0e1c15 Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Tue, 30 Nov 2021 12:01:04 -0800 Subject: [PATCH 3/3] Removing an extra new-line I added by accident Signed-off-by: Gene Walters --- .../Code/Source/Editor/MultiplayerEditorSystemComponent.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp index 259d544279..ec783808a2 100644 --- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp @@ -6,7 +6,6 @@ * */ - #include #include #include