Address string/mem feedback plus some misc cleanup
This commit is contained in:
@@ -12,16 +12,17 @@
|
||||
|
||||
#include <Multiplayer/IMultiplayer.h>
|
||||
#include <Multiplayer/MultiplayerConstants.h>
|
||||
#include <Source/Editor/MultiplayerEditorConnection.h>
|
||||
#include <Editor/MultiplayerEditorConnection.h>
|
||||
#include <Source/AutoGen/AutoComponentTypes.h>
|
||||
#include <AzNetworking/ConnectionLayer/IConnection.h>
|
||||
#include <AzNetworking/Framework/INetworking.h>
|
||||
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/Utils.h>
|
||||
#include <AzFramework/Spawnable/Spawnable.h>
|
||||
#include <AzNetworking/ConnectionLayer/IConnection.h>
|
||||
#include <AzNetworking/Framework/INetworking.h>
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Source/Multiplayer_precompiled.h>
|
||||
#include <Source/MultiplayerGem.h>
|
||||
#include <Source/MultiplayerSystemComponent.h>
|
||||
#include <Source/Editor/MultiplayerEditorGem.h>
|
||||
#include <AzNetworking/Framework/NetworkingSystemComponent.h>
|
||||
#include <Multiplayer_precompiled.h>
|
||||
#include <MultiplayerGem.h>
|
||||
#include <MultiplayerSystemComponent.h>
|
||||
#include <Editor/MultiplayerEditorGem.h>
|
||||
#include <Editor/MultiplayerEditorSystemComponent.h>
|
||||
|
||||
#include <Source/Editor/MultiplayerEditorSystemComponent.h>
|
||||
#include <AzNetworking/Framework/NetworkingSystemComponent.h>
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
|
||||
@@ -13,13 +13,15 @@
|
||||
#include <Multiplayer/IMultiplayer.h>
|
||||
#include <Multiplayer/IMultiplayerTools.h>
|
||||
#include <Multiplayer/MultiplayerConstants.h>
|
||||
|
||||
#include <MultiplayerSystemComponent.h>
|
||||
#include <Editor/MultiplayerEditorSystemComponent.h>
|
||||
#include <Source/AutoGen/Multiplayer.AutoPackets.h>
|
||||
#include <Source/MultiplayerSystemComponent.h>
|
||||
#include <Source/Editor/MultiplayerEditorSystemComponent.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzNetworking/Framework/INetworking.h>
|
||||
@@ -31,11 +33,11 @@ namespace Multiplayer
|
||||
|
||||
AZ_CVAR(bool, editorsv_enabled, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate,
|
||||
"Whether Editor launching a local server to connect to is supported");
|
||||
AZ_CVAR(bool, editorsv_launch, false, nullptr, AZ::ConsoleFunctorFlags::DontReplicate,
|
||||
AZ_CVAR(bool, editorsv_launch, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate,
|
||||
"Whether Editor should launch a server when the server address is localhost");
|
||||
AZ_CVAR(AZ::CVarFixedString, editorsv_process, "", nullptr, AZ::ConsoleFunctorFlags::DontReplicate,
|
||||
"The server executable that should be run. Empty to use the current project's ServerLauncher");
|
||||
AZ_CVAR(AZ::CVarFixedString, editorsv_serveraddr, LocalHost.data(), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The address of the server to connect to");
|
||||
AZ_CVAR(AZ::CVarFixedString, editorsv_serveraddr, AZ::CVarFixedString(LocalHost), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The address of the server to connect to");
|
||||
AZ_CVAR(uint16_t, editorsv_port, DefaultServerEditorPort, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The port that the multiplayer editor gem will bind to for traffic");
|
||||
|
||||
void MultiplayerEditorSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
@@ -115,34 +117,24 @@ namespace Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
void LaunchEditorServer(AzFramework::ProcessWatcher* outProcess)
|
||||
AzFramework::ProcessWatcher* LaunchEditorServer()
|
||||
{
|
||||
// Assemble the server's path
|
||||
AZ::CVarFixedString serverProcess = editorsv_process;
|
||||
AZ::IO::FixedMaxPath serverPath;
|
||||
if (serverProcess.empty())
|
||||
{
|
||||
// If enabled but no process name is supplied, try this project's ServerLauncher
|
||||
serverProcess = AZ::Utils::GetProjectName() + ".ServerLauncher";
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPathString serverPath = AZ::Utils::GetExecutableDirectory();
|
||||
if (!serverProcess.contains(AZ_TRAIT_OS_PATH_SEPARATOR))
|
||||
{
|
||||
// If only the process name is specified, append that as well
|
||||
serverPath.append(AZ_TRAIT_OS_PATH_SEPARATOR + serverProcess);
|
||||
serverPath = AZ::Utils::GetExecutableDirectory();
|
||||
serverPath /= serverProcess + AZ_TRAIT_OS_EXECUTABLE_EXTENSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If any path was already specified, then simply assign
|
||||
serverPath = serverProcess;
|
||||
}
|
||||
|
||||
if (!serverProcess.ends_with(AZ_TRAIT_OS_EXECUTABLE_EXTENSION))
|
||||
{
|
||||
// Add this platform's exe extension if it's not specified
|
||||
serverPath.append(AZ_TRAIT_OS_EXECUTABLE_EXTENSION);
|
||||
}
|
||||
|
||||
// Start the configured server if it's available
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
processLaunchInfo.m_commandlineParameters = AZStd::string::format("\"%s\" --editorsv_isDedicated true", serverPath.c_str());
|
||||
@@ -150,9 +142,11 @@ namespace Multiplayer
|
||||
processLaunchInfo.m_processPriority = AzFramework::ProcessPriority::PROCESSPRIORITY_NORMAL;
|
||||
|
||||
// Launch the Server and give it a few seconds to boot up
|
||||
outProcess = AzFramework::ProcessWatcher::LaunchProcess(
|
||||
AzFramework::ProcessWatcher* outProcess = AzFramework::ProcessWatcher::LaunchProcess(
|
||||
processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE);
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(15000));
|
||||
|
||||
return outProcess;
|
||||
}
|
||||
|
||||
void MultiplayerEditorSystemComponent::OnGameEntitiesStarted()
|
||||
@@ -188,9 +182,9 @@ namespace Multiplayer
|
||||
}
|
||||
|
||||
const AZ::CVarFixedString remoteAddress = editorsv_serveraddr;
|
||||
if (editorsv_launch && LocalHost.compare(remoteAddress.c_str()) == 0)
|
||||
if (editorsv_launch && LocalHost == remoteAddress)
|
||||
{
|
||||
LaunchEditorServer(m_serverProcess);
|
||||
m_serverProcess = LaunchEditorServer();
|
||||
}
|
||||
|
||||
// Now that the server has launched, attempt to connect the NetworkInterface
|
||||
|
||||
@@ -14,18 +14,16 @@
|
||||
|
||||
#include <IEditor.h>
|
||||
|
||||
#include <Source/Editor/MultiplayerEditorConnection.h>
|
||||
#include <Editor/MultiplayerEditorConnection.h>
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
|
||||
#include <AzFramework/Entity/GameEntityContextBus.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
|
||||
|
||||
namespace AzNetworking
|
||||
{
|
||||
class INetworkInterface;
|
||||
|
||||
Reference in New Issue
Block a user