From e5aa56d565d19210ec40d183b965011c5fcdf65e Mon Sep 17 00:00:00 2001 From: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com> Date: Wed, 23 Jun 2021 09:38:43 -0400 Subject: [PATCH] Added a runtime switch to turn on/off removal of player spawnable on disconnect --- .../Source/ConnectionData/ServerToClientConnectionData.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.cpp b/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.cpp index 45ac9cd850..ca6de98911 100644 --- a/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.cpp +++ b/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.cpp @@ -19,6 +19,7 @@ namespace Multiplayer AZ_CVAR(uint32_t, sv_ClientMaxRemoteEntitiesPendingCreationCount, AZStd::numeric_limits::max(), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Maximum number of entities that we have sent to the client, but have not had a confirmation back from the client"); AZ_CVAR(uint32_t, sv_ClientMaxRemoteEntitiesPendingCreationCountPostInit, AZStd::numeric_limits::max(), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Maximum number of entities that we will send to clients after gameplay has begun"); AZ_CVAR(AZ::TimeMs, sv_ClientEntityReplicatorPendingRemovalTimeMs, AZ::TimeMs{ 10000 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "How long should wait prior to removing an entity for the client through a change in the replication window, entity deletes are still immediate"); + AZ_CVAR(bool, sv_removeDefaultPlayerSpawnableOnDisconnect, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Whether to remove player's default spawnable when a player disconnects"); ServerToClientConnectionData::ServerToClientConnectionData ( @@ -45,7 +46,10 @@ namespace Multiplayer ServerToClientConnectionData::~ServerToClientConnectionData() { - AZ::Interface::Get()->GetNetworkEntityManager()->MarkForRemoval(m_controlledEntity); + if (sv_removeDefaultPlayerSpawnableOnDisconnect) + { + AZ::Interface::Get()->GetNetworkEntityManager()->MarkForRemoval(m_controlledEntity); + } m_entityReplicationManager.Clear(false); m_controlledEntityRemovedHandler.Disconnect();