sig/network - bugfix - removal of player prefabs on disconnect

sig/network - bugfix - removal of player prefabs on disconnect
This commit is contained in:
Olex Lozitskiy
2021-06-24 15:01:41 -05:00
committed by GitHub
6 changed files with 30 additions and 22 deletions
@@ -6,6 +6,7 @@
*/
#include <Source/ConnectionData/ServerToClientConnectionData.h>
#include <Multiplayer/IMultiplayer.h>
namespace Multiplayer
{
@@ -13,6 +14,7 @@ namespace Multiplayer
AZ_CVAR(uint32_t, sv_ClientMaxRemoteEntitiesPendingCreationCount, AZStd::numeric_limits<uint32_t>::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<uint32_t>::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
(
@@ -39,6 +41,11 @@ namespace Multiplayer
ServerToClientConnectionData::~ServerToClientConnectionData()
{
if (sv_removeDefaultPlayerSpawnableOnDisconnect)
{
AZ::Interface<IMultiplayer>::Get()->GetNetworkEntityManager()->MarkForRemoval(m_controlledEntity);
}
m_entityReplicationManager.Clear(false);
m_controlledEntityRemovedHandler.Disconnect();
}