sig/network - bugfix - removal of player prefabs on disconnect
sig/network - bugfix - removal of player prefabs on disconnect
This commit is contained in:
@@ -1673,12 +1673,18 @@ namespace {{ Component.attrib['Namespace'] }}
|
|||||||
|
|
||||||
void {{ ComponentBaseName }}::ActivateController(Multiplayer::EntityIsMigrating entityIsMigrating)
|
void {{ ComponentBaseName }}::ActivateController(Multiplayer::EntityIsMigrating entityIsMigrating)
|
||||||
{
|
{
|
||||||
m_controller.get()->Activate(entityIsMigrating);
|
if (m_controller)
|
||||||
|
{
|
||||||
|
m_controller->Activate(entityIsMigrating);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{ ComponentBaseName }}::DeactivateController(Multiplayer::EntityIsMigrating entityIsMigrating)
|
void {{ ComponentBaseName }}::DeactivateController(Multiplayer::EntityIsMigrating entityIsMigrating)
|
||||||
{
|
{
|
||||||
m_controller.get()->Deactivate(entityIsMigrating);
|
if (m_controller)
|
||||||
|
{
|
||||||
|
m_controller->Deactivate(entityIsMigrating);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{ ComponentBaseName }}::NetworkAttach(Multiplayer::NetBindComponent* netBindComponent, Multiplayer::ReplicationRecord& currentEntityRecord, Multiplayer::ReplicationRecord& predictableEntityRecord)
|
void {{ ComponentBaseName }}::NetworkAttach(Multiplayer::NetBindComponent* netBindComponent, Multiplayer::ReplicationRecord& currentEntityRecord, Multiplayer::ReplicationRecord& predictableEntityRecord)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Source/ConnectionData/ServerToClientConnectionData.h>
|
#include <Source/ConnectionData/ServerToClientConnectionData.h>
|
||||||
|
#include <Multiplayer/IMultiplayer.h>
|
||||||
|
|
||||||
namespace Multiplayer
|
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_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(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(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
|
ServerToClientConnectionData::ServerToClientConnectionData
|
||||||
(
|
(
|
||||||
@@ -39,6 +41,11 @@ namespace Multiplayer
|
|||||||
|
|
||||||
ServerToClientConnectionData::~ServerToClientConnectionData()
|
ServerToClientConnectionData::~ServerToClientConnectionData()
|
||||||
{
|
{
|
||||||
|
if (sv_removeDefaultPlayerSpawnableOnDisconnect)
|
||||||
|
{
|
||||||
|
AZ::Interface<IMultiplayer>::Get()->GetNetworkEntityManager()->MarkForRemoval(m_controlledEntity);
|
||||||
|
}
|
||||||
|
|
||||||
m_entityReplicationManager.Clear(false);
|
m_entityReplicationManager.Clear(false);
|
||||||
m_controlledEntityRemovedHandler.Disconnect();
|
m_controlledEntityRemovedHandler.Disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -34,7 +34,9 @@ namespace Multiplayer
|
|||||||
{
|
{
|
||||||
class IEntityDomain;
|
class IEntityDomain;
|
||||||
class EntityReplicator;
|
class EntityReplicator;
|
||||||
|
|
||||||
|
//! @class EntityReplicationManager
|
||||||
|
//! @brief Handles replication of relevant entities for one connection.
|
||||||
class EntityReplicationManager final
|
class EntityReplicationManager final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -277,15 +277,6 @@ namespace Multiplayer
|
|||||||
{
|
{
|
||||||
//RewindableObjectState::ClearRewoundEntities();
|
//RewindableObjectState::ClearRewoundEntities();
|
||||||
|
|
||||||
// Keystone has refactored these API's, rewrite required
|
|
||||||
//AZ::SliceComponent* rootSlice = nullptr;
|
|
||||||
//{
|
|
||||||
// AzFramework::EntityContextId gameContextId = AzFramework::EntityContextId::CreateNull();
|
|
||||||
// AzFramework::GameEntityContextRequestBus::BroadcastResult(gameContextId, &AzFramework::GameEntityContextRequests::GetGameEntityContextId);
|
|
||||||
// AzFramework::EntityContextRequestBus::BroadcastResult(rootSlice, &AzFramework::EntityContextRequests::GetRootSlice);
|
|
||||||
// AZ_Assert(rootSlice != nullptr, "Root slice returned was NULL");
|
|
||||||
//}
|
|
||||||
|
|
||||||
AZStd::vector<NetEntityId> removeList;
|
AZStd::vector<NetEntityId> removeList;
|
||||||
removeList.swap(m_removeList);
|
removeList.swap(m_removeList);
|
||||||
for (NetEntityId entityId : removeList)
|
for (NetEntityId entityId : removeList)
|
||||||
@@ -299,13 +290,12 @@ namespace Multiplayer
|
|||||||
AZ_Assert(netBindComponent != nullptr, "NetBindComponent not found on networked entity");
|
AZ_Assert(netBindComponent != nullptr, "NetBindComponent not found on networked entity");
|
||||||
netBindComponent->StopEntity();
|
netBindComponent->StopEntity();
|
||||||
|
|
||||||
// Delete Entity, method depends on how it was loaded
|
// At the moment, we spawn one entity at a time and avoid Prefab API calls and never get a spawn ticket,
|
||||||
// Try slice removal first, then force delete
|
// so this is the right way for now. Once we support prefabs we can use AzFramework::SpawnableEntitiesContainer
|
||||||
//AZ::Entity* rawEntity = removeEntity.GetEntity();
|
// Additionally, prefabs spawning is async! Whereas we currently create entities immediately, see:
|
||||||
//if (!rootSlice->RemoveEntity(rawEntity))
|
// @NetworkEntityManager::CreateEntitiesImmediate
|
||||||
//{
|
AzFramework::GameEntityContextRequestBus::Broadcast(
|
||||||
// delete rawEntity;
|
&AzFramework::GameEntityContextRequestBus::Events::DestroyGameEntity, netBindComponent->GetEntityId());
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_networkEntityTracker.erase(entityId);
|
m_networkEntityTracker.erase(entityId);
|
||||||
|
|||||||
@@ -59,10 +59,11 @@ namespace Multiplayer
|
|||||||
|
|
||||||
NetworkEntityUpdateMessage::NetworkEntityUpdateMessage(NetEntityId entityId, bool wasMigrated, bool takeOwnership)
|
NetworkEntityUpdateMessage::NetworkEntityUpdateMessage(NetEntityId entityId, bool wasMigrated, bool takeOwnership)
|
||||||
: m_entityId(entityId)
|
: m_entityId(entityId)
|
||||||
|
, m_isDelete(true)
|
||||||
, m_wasMigrated(wasMigrated)
|
, m_wasMigrated(wasMigrated)
|
||||||
, m_takeOwnership(takeOwnership)
|
, m_takeOwnership(takeOwnership)
|
||||||
{
|
{
|
||||||
;
|
// this is a delete entity message c-tor
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkEntityUpdateMessage& NetworkEntityUpdateMessage::operator =(NetworkEntityUpdateMessage&& rhs)
|
NetworkEntityUpdateMessage& NetworkEntityUpdateMessage::operator =(NetworkEntityUpdateMessage&& rhs)
|
||||||
|
|||||||
@@ -123,8 +123,10 @@ namespace Multiplayer
|
|||||||
|
|
||||||
for (NetworkEntityHandle entityHandle : m_rewoundEntities)
|
for (NetworkEntityHandle entityHandle : m_rewoundEntities)
|
||||||
{
|
{
|
||||||
NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent();
|
if (NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent())
|
||||||
netBindComponent->NotifySyncRewindState();
|
{
|
||||||
|
netBindComponent->NotifySyncRewindState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_rewoundEntities.clear();
|
m_rewoundEntities.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user