Integrating up through commit 90f050496

This commit is contained in:
alexpete
2021-04-07 14:03:29 -07:00
parent 8f2ed080a9
commit c2cbd430fe
2694 changed files with 285622 additions and 176874 deletions
@@ -216,7 +216,7 @@ namespace Multiplayer
m_remoteEntitiesPendingCreation.insert(entityId);
}
if (replicator->GetRemoteNetworkRole() == NetEntityRole::ClientAutonomous)
if (replicator->GetRemoteNetworkRole() == NetEntityRole::Autonomous)
{
autonomousReplicators.push_back(replicator);
}
@@ -557,7 +557,7 @@ namespace Multiplayer
const bool changeNetworkRole = (netBindComponent->GetNetEntityRole() != localNetworkRole);
if (changeNetworkRole)
{
AZ_Assert(localNetworkRole != NetEntityRole::ServerAuthority, "UpdateMessage trying to set local role to ServerAuthority, this should only happen via migration");
AZ_Assert(localNetworkRole != NetEntityRole::Authority, "UpdateMessage trying to set local role to Authority, this should only happen via migration");
AZLOG_INFO
(
"EntityReplicationManager: Changing network role on entity %u, old role %u new role %u",
@@ -590,14 +590,14 @@ namespace Multiplayer
// A will tell us to set a timer to delete that entity (since it no longer owns it, and has been handed off), and B will tell us to create it.
// This covers an edge case where the timer has popped, but the entity is pending removal when we are told by B to create the entity.
GetNetworkEntityManager()->ClearEntityFromRemovalList(replicatorEntity);
entityReplicator = AddEntityReplicator(replicatorEntity, NetEntityRole::ServerAuthority);
entityReplicator = AddEntityReplicator(replicatorEntity, NetEntityRole::Authority);
//AZLOG(NET_RepUpdate, "EntityReplicationManager: Created from update entity id %u for type %s role %d", netEntityId, prefabEntityId.GetString(), localNetworkRole);
}
// @nt: TODO - delete once dropped RPC problem fixed
// This code is temporary to work around to the problem that RPC messages are silently lost during migration
// Once this problem is solved, we can remove this code and associated event
if (createReplicator && localNetworkRole == NetEntityRole::ClientAutonomous)
if (createReplicator && localNetworkRole == NetEntityRole::Autonomous)
{
m_autonomousEntityReplicatorCreated.Signal(netEntityId);
}
@@ -647,10 +647,10 @@ namespace Multiplayer
// don't trust the client by default
result = UpdateValidationResult::DropMessageAndDisconnect;
// Clients sending data must have a replicator and be sending in the correct mode, further, they must have a replicator and can never delete a replicator
if (updateMessage.GetNetworkRole() == NetEntityRole::ServerAuthority && entityReplicator && !updateMessage.GetIsDelete())
if (updateMessage.GetNetworkRole() == NetEntityRole::Authority && entityReplicator && !updateMessage.GetIsDelete())
{
// Make sure we our replicator is in the expected configuration
if ((entityReplicator->GetRemoteNetworkRole() == NetEntityRole::ClientAutonomous) && (entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority))
if ((entityReplicator->GetRemoteNetworkRole() == NetEntityRole::Autonomous) && (entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::Authority))
{
// If we're marked for removal, just drop the message - migration message is likely in flight
if (entityReplicator->IsMarkedForRemoval())
@@ -663,7 +663,7 @@ namespace Multiplayer
result = UpdateValidationResult::HandleMessage;
}
} // If we've migrated the entity away from the server, but we get this late, just drop it
else if ((entityReplicator->GetRemoteNetworkRole() == NetEntityRole::ClientSimulation) && (entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::ServerSimulation))
else if ((entityReplicator->GetRemoteNetworkRole() == NetEntityRole::Client) && (entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::Server))
{
result = UpdateValidationResult::DropMessage;
}
@@ -686,22 +686,22 @@ namespace Multiplayer
break;
case Mode::LocalServerToRemoteServer:
{
AZ_Assert(updateMessage.GetNetworkRole() == NetEntityRole::ServerSimulation || updateMessage.GetIsDelete(), "Unexpected update type coming from peer server");
AZ_Assert(updateMessage.GetNetworkRole() == NetEntityRole::Server || updateMessage.GetIsDelete(), "Unexpected update type coming from peer server");
// trust messages from a peer server by default
result = UpdateValidationResult::HandleMessage;
// If we have a replicator, make sure we're in the correct state
if (entityReplicator)
{
if (!entityReplicator->IsMarkedForRemoval() && (entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority))
if (!entityReplicator->IsMarkedForRemoval() && (entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::Authority))
{
// Likely an old message from a previous owner trying to delete the replicator it had, while we've received ownership
// This can happen when Shard A migrates an entity to Shard B, then shard B migrates the entity to Shard C, and Shard A tries to delete a replicator it had to Shard C (which has already made a new replicator for Shard A)
result = UpdateValidationResult::DropMessage;
}
else if (entityReplicator->GetRemoteNetworkRole() != NetEntityRole::ServerAuthority)// we expect to the remote role to be e_ServerAuthority
else if (entityReplicator->GetRemoteNetworkRole() != NetEntityRole::Authority)// we expect to the remote role to be e_Authority
{
// This entity has migrated previously, and we haven't heard back that the remove was successful, so we can accept the message
AZ_Assert(entityReplicator->IsMarkedForRemoval() && entityReplicator->GetRemoteNetworkRole() == NetEntityRole::ServerSimulation, "Unexpected server message is not Authority or ServerSimulation");
AZ_Assert(entityReplicator->IsMarkedForRemoval() && entityReplicator->GetRemoteNetworkRole() == NetEntityRole::Server, "Unexpected server message is not Authority or Server");
}
}
}
@@ -1018,9 +1018,9 @@ namespace Multiplayer
AZ_Assert(netBindComponent, "No NetBindComponent");
const EntityReplicator* entityReplicator = GetEntityReplicator(entityHandle.GetNetEntityId());
hasAuthority = (netBindComponent->GetNetEntityRole() == NetEntityRole::ServerAuthority); // Make sure someone hasn't migrated this already
hasAuthority = (netBindComponent->GetNetEntityRole() == NetEntityRole::Authority); // Make sure someone hasn't migrated this already
isInDomain = (m_remoteEntityDomain && m_remoteEntityDomain->IsInDomain(entityHandle)); // Make sure the remote side would want it
if (entityReplicator && entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority)
if (entityReplicator && entityReplicator->GetBoundLocalNetworkRole() == NetEntityRole::Authority)
{
isMarkedForRemoval = entityReplicator->IsMarkedForRemoval(); // Make sure we aren't telling the other side to remove the replicator
const PropertyPublisher* propertyPublisher = entityReplicator->GetPropertyPublisher();
@@ -1035,7 +1035,7 @@ namespace Multiplayer
{
if (const EntityReplicator* replicator = GetEntityReplicator(entityHandle.GetNetEntityId()))
{
return replicator->GetRemoteNetworkRole() == NetEntityRole::ServerAuthority;
return replicator->GetRemoteNetworkRole() == NetEntityRole::Authority;
}
return false;
}
@@ -1073,9 +1073,9 @@ namespace Multiplayer
NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent();
AZ_Assert(netBindComponent, "No NetBindComponent");
if (netBindComponent && netBindComponent->GetNetEntityRole() == NetEntityRole::ServerAuthority)
if (netBindComponent && netBindComponent->GetNetEntityRole() == NetEntityRole::Authority)
{
EntityReplicator* replicator = AddEntityReplicator(entityHandle, NetEntityRole::ServerSimulation);
EntityReplicator* replicator = AddEntityReplicator(entityHandle, NetEntityRole::Server);
PropertyPublisher* propPublisher = replicator->GetPropertyPublisher();
AZ_Assert(propPublisher, "Assumed we have a property publisher");
@@ -1092,15 +1092,11 @@ namespace Multiplayer
if (localEnt->GetState() == AZ::Entity::State::Active)
{
netBindComponent->DeactivateControllers(EntityIsMigrating::True);
AzNetworking::NetworkInputSerializer inputSerializer(message.ModifyMigrationData().GetBuffer(), message.ModifyMigrationData().GetCapacity());
didSucceed = netBindComponent->SerializeMigrationData(inputSerializer);
message.ModifyMigrationData().Resize(inputSerializer.GetSize());
}
netBindComponent->DestructControllers();
netBindComponent->SetMigrationDataValid(false);
// save off network properties after the migration data is saved to capture any changes that might have occurred during deactivate
// Gather the most recent network property state, including authoritative only network properties for migration
{
// Send an update packet if it needs one
propPublisher->GenerateRecord();
@@ -1119,7 +1115,7 @@ namespace Multiplayer
AZLOG(NET_RepDeletes, "Migration packet sent %u to remote manager id %d", netEntityId, aznumeric_cast<int32_t>(GetRemoteHostId()));
// Immediately add a new replicator so that we catch RPC invocations, the remote side will make us a new one, and then remove us if needs be
AddEntityReplicator(entityHandle, NetEntityRole::ServerAuthority);
AddEntityReplicator(entityHandle, NetEntityRole::Authority);
}
}
@@ -1135,7 +1131,7 @@ namespace Multiplayer
replicator,
AzNetworking::InvalidPacketId,
message.GetEntityId(),
NetEntityRole::ServerSimulation,
NetEntityRole::Server,
outputSerializer,
message.GetPrefabEntityId()
))
@@ -1159,15 +1155,6 @@ namespace Multiplayer
// Stop listening to the OnEntityNetworkRoleChange, since we are about to change it and we don't want that callback
netBindComponent->ConstructControllers();
bool didSucceed = false;
{
AzNetworking::NetworkOutputSerializer outputSerializer(message.ModifyMigrationData().GetBuffer(), message.ModifyMigrationData().GetSize());
didSucceed = netBindComponent->SerializeMigrationData(outputSerializer);
AZ_Assert(didSucceed, "Failed to migrate entity to server");
AZ_Assert(outputSerializer.IsValid() && outputSerializer.GetUnreadSize() == 0, "Bad migration");
}
netBindComponent->SetMigrationDataValid(true);
if (entityHandle.GetEntity()->GetState() == AZ::Entity::State::Active)
{
// Only activate controllers if the entity was previously activated, otherwise, wait for the normal entity activation flow
@@ -1175,10 +1162,10 @@ namespace Multiplayer
}
// change the role on the replicator
AddEntityReplicator(entityHandle, NetEntityRole::ServerSimulation);
AddEntityReplicator(entityHandle, NetEntityRole::Server);
AZLOG(NET_RepDeletes, "Handle Migration %u new authority from remote manager id %d", entityHandle.GetNetEntityId(), aznumeric_cast<int32_t>(GetRemoteHostId()));
return didSucceed;
return true;
}
void EntityReplicationManager::OnEntityExitDomain(const ConstNetworkEntityHandle& entityHandle)
@@ -50,8 +50,8 @@ namespace Multiplayer
, m_onEntityDirtiedHandler([this]() { OnEntityDirtiedEvent(); })
, m_onSendRpcHandler([this](NetworkEntityRpcMessage& entityRpcMessage) { OnSendRpcEvent(entityRpcMessage); })
, m_onForwardRpcHandler([this](NetworkEntityRpcMessage& entityRpcMessage) { OnSendRpcEvent(entityRpcMessage); })
, m_onSendClientAutonomousRpcHandler([this](NetworkEntityRpcMessage& entityRpcMessage) { OnSendRpcEvent(entityRpcMessage); })
, m_onForwardClientAutonomousRpcHandler([this](NetworkEntityRpcMessage& entityRpcMessage) { OnSendRpcEvent(entityRpcMessage); })
, m_onSendAutonomousRpcHandler([this](NetworkEntityRpcMessage& entityRpcMessage) { OnSendRpcEvent(entityRpcMessage); })
, m_onForwardAutonomousRpcHandler([this](NetworkEntityRpcMessage& entityRpcMessage) { OnSendRpcEvent(entityRpcMessage); })
, m_onEntityStopHandler([this](const ConstNetworkEntityHandle &) { OnEntityRemovedEvent(); })
, m_proxyRemovalEvent([this] { OnProxyRemovalTimedEvent(); }, AZ::Name("ProxyRemovalTimedEvent"))
{
@@ -73,11 +73,11 @@ namespace Multiplayer
m_prefabEntityIdSet = true;
}
void EntityReplicator::Reset(NetEntityRole a_RemoteNetworkRole)
void EntityReplicator::Reset(NetEntityRole remoteNetworkRole)
{
AZ::EntityBus::Handler::BusDisconnect();
m_remoteNetworkRole = a_RemoteNetworkRole;
m_remoteNetworkRole = remoteNetworkRole;
m_propertyPublisher = nullptr;
m_propertySubscriber = nullptr;
@@ -86,8 +86,8 @@ namespace Multiplayer
m_onSendRpcHandler.Disconnect();
m_onForwardRpcHandler.Disconnect();
m_onSendClientAutonomousRpcHandler.Disconnect();
m_onForwardClientAutonomousRpcHandler.Disconnect();
m_onSendAutonomousRpcHandler.Disconnect();
m_onForwardAutonomousRpcHandler.Disconnect();
m_onEntityStopHandler.Disconnect();
}
@@ -136,8 +136,8 @@ namespace Multiplayer
m_propertyPublisher = nullptr;
}
if (m_remoteNetworkRole == NetEntityRole::ServerAuthority ||
m_remoteNetworkRole == NetEntityRole::ClientAutonomous)
if (m_remoteNetworkRole == NetEntityRole::Authority ||
m_remoteNetworkRole == NetEntityRole::Autonomous)
{
m_propertySubscriber = AZStd::make_unique<PropertySubscriber>(m_replicationManager, m_netBindComponent);
}
@@ -165,9 +165,9 @@ namespace Multiplayer
{
// Make sure all handlers are detached first
m_onSendRpcHandler.Disconnect();
m_onSendClientAutonomousRpcHandler.Disconnect();
m_onSendAutonomousRpcHandler.Disconnect();
m_onForwardRpcHandler.Disconnect();
m_onForwardClientAutonomousRpcHandler.Disconnect();
m_onForwardAutonomousRpcHandler.Disconnect();
if (auto localEntity = m_entityHandle.GetEntity())
{
@@ -176,49 +176,49 @@ namespace Multiplayer
switch (GetBoundLocalNetworkRole())
{
case NetEntityRole::ServerAuthority:
case NetEntityRole::Authority:
{
if (GetRemoteNetworkRole() == NetEntityRole::ClientSimulation || GetRemoteNetworkRole() == NetEntityRole::ClientAutonomous)
if (GetRemoteNetworkRole() == NetEntityRole::Client || GetRemoteNetworkRole() == NetEntityRole::Autonomous)
{
m_onSendRpcHandler.Connect(netBindComponent->GetSendServerAuthorityToClientSimulationRpcEvent());
if (GetRemoteNetworkRole() == NetEntityRole::ClientAutonomous)
m_onSendRpcHandler.Connect(netBindComponent->GetSendAuthorityToClientRpcEvent());
if (GetRemoteNetworkRole() == NetEntityRole::Autonomous)
{
m_onSendClientAutonomousRpcHandler.Connect(netBindComponent->GetSendServerAuthorityToClientAutonomousRpcEvent());
m_onSendAutonomousRpcHandler.Connect(netBindComponent->GetSendAuthorityToAutonomousRpcEvent());
}
}
else if (GetRemoteNetworkRole() == NetEntityRole::ServerSimulation)
else if (GetRemoteNetworkRole() == NetEntityRole::Server)
{
m_onForwardRpcHandler.Connect(netBindComponent->GetSendServerAuthorityToClientSimulationRpcEvent());
m_onForwardRpcHandler.Connect(netBindComponent->GetSendAuthorityToClientRpcEvent());
}
}
break;
case NetEntityRole::ServerSimulation:
case NetEntityRole::Server:
{
if (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority)
if (GetRemoteNetworkRole() == NetEntityRole::Authority)
{
m_onSendRpcHandler.Connect(netBindComponent->GetSendServerSimulationToServerAuthorityRpcEvent());
m_onForwardRpcHandler.Connect(netBindComponent->GetSendServerAuthorityToClientSimulationRpcEvent());
m_onForwardClientAutonomousRpcHandler.Connect(netBindComponent->GetSendServerAuthorityToClientAutonomousRpcEvent());
m_onSendRpcHandler.Connect(netBindComponent->GetSendServerToAuthorityRpcEvent());
m_onForwardRpcHandler.Connect(netBindComponent->GetSendAuthorityToClientRpcEvent());
m_onForwardAutonomousRpcHandler.Connect(netBindComponent->GetSendAuthorityToAutonomousRpcEvent());
}
else if (GetRemoteNetworkRole() == NetEntityRole::ClientSimulation)
else if (GetRemoteNetworkRole() == NetEntityRole::Client)
{
// Listen for these to forward the rpc along to the other Client replicators
m_onSendRpcHandler.Connect(netBindComponent->GetSendServerAuthorityToClientSimulationRpcEvent());
m_onSendRpcHandler.Connect(netBindComponent->GetSendAuthorityToClientRpcEvent());
}
// NOTE: e_ClientAutonomous is not connected to e_ServerProxy, it is always connected to an e_ServerAuthority
AZ_Assert(GetRemoteNetworkRole() != NetEntityRole::ClientAutonomous, "Unexpected autonomous remote role")
// NOTE: e_Autonomous is not connected to e_ServerProxy, it is always connected to an e_Authority
AZ_Assert(GetRemoteNetworkRole() != NetEntityRole::Autonomous, "Unexpected autonomous remote role")
}
break;
case NetEntityRole::ClientSimulation:
case NetEntityRole::Client:
{
// Nothing allowed, no ClientSimulation to Server communication
// Nothing allowed, no Client to Server communication
}
break;
case NetEntityRole::ClientAutonomous:
case NetEntityRole::Autonomous:
{
if (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority)
if (GetRemoteNetworkRole() == NetEntityRole::Authority)
{
m_onSendRpcHandler.Connect(netBindComponent->GetSendClientAutonomousToServerAuthorityRpcEvent());
m_onSendRpcHandler.Connect(netBindComponent->GetSendAutonomousToAuthorityRpcEvent());
}
}
break;
@@ -282,11 +282,11 @@ namespace Multiplayer
NetBindComponent* netBindComponent = m_netBindComponent;
AZ_Assert(netBindComponent, "No Multiplayer::NetBindComponent");
bool isServerAuthority = (GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority)
bool isAuthority = (GetBoundLocalNetworkRole() == NetEntityRole::Authority)
&& (GetBoundLocalNetworkRole() == netBindComponent->GetNetEntityRole());
bool isClientSimulation = GetRemoteNetworkRole() == NetEntityRole::ClientSimulation;
bool isClientAutonomous = GetBoundLocalNetworkRole() == NetEntityRole::ClientAutonomous;
if (isServerAuthority || isClientSimulation || isClientAutonomous)
bool isClient = GetRemoteNetworkRole() == NetEntityRole::Client;
bool isAutonomous = GetBoundLocalNetworkRole() == NetEntityRole::Autonomous;
if (isAuthority || isClient || isAutonomous)
{
ret = true;
}
@@ -297,10 +297,10 @@ namespace Multiplayer
bool EntityReplicator::OwnsReplicatorLifetime() const
{
bool ret(false);
if (GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority
|| (GetBoundLocalNetworkRole() == NetEntityRole::ServerSimulation
&& (GetRemoteNetworkRole() == NetEntityRole::ClientSimulation
|| GetRemoteNetworkRole() == NetEntityRole::ClientAutonomous)))
if (GetBoundLocalNetworkRole() == NetEntityRole::Authority
|| (GetBoundLocalNetworkRole() == NetEntityRole::Server
&& (GetRemoteNetworkRole() == NetEntityRole::Client
|| GetRemoteNetworkRole() == NetEntityRole::Autonomous)))
{
ret = true;
}
@@ -310,11 +310,11 @@ namespace Multiplayer
bool EntityReplicator::RemoteManagerOwnsEntityLifetime() const
{
bool ret(false);
bool isServerSimulation = (GetBoundLocalNetworkRole() == NetEntityRole::ServerSimulation)
&& (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority);
bool isClientSimulation = (GetBoundLocalNetworkRole() == NetEntityRole::ClientSimulation)
|| (GetBoundLocalNetworkRole() == NetEntityRole::ClientAutonomous);
if (isServerSimulation || isClientSimulation)
bool isServer = (GetBoundLocalNetworkRole() == NetEntityRole::Server)
&& (GetRemoteNetworkRole() == NetEntityRole::Authority);
bool isClient = (GetBoundLocalNetworkRole() == NetEntityRole::Client)
|| (GetBoundLocalNetworkRole() == NetEntityRole::Autonomous);
if (isServer || isClient)
{
ret = true;
}
@@ -346,7 +346,7 @@ namespace Multiplayer
m_replicationManager.AddReplicatorToPendingRemoval(*this);
m_onForwardRpcHandler.Disconnect();
m_onForwardClientAutonomousRpcHandler.Disconnect();
m_onForwardAutonomousRpcHandler.Disconnect();
m_onEntityStopHandler.Disconnect();
}
@@ -492,32 +492,32 @@ namespace Multiplayer
RpcValidationResult result = RpcValidationResult::DropRpcAndDisconnect;
switch (entityRpcMessage.GetRpcDeliveryType())
{
case RpcDeliveryType::ServerAuthorityToClientSimulation:
case RpcDeliveryType::AuthorityToClient:
{
if (((GetBoundLocalNetworkRole() == NetEntityRole::ClientSimulation) || (GetBoundLocalNetworkRole() == NetEntityRole::ClientAutonomous))
&& (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority))
if (((GetBoundLocalNetworkRole() == NetEntityRole::Client) || (GetBoundLocalNetworkRole() == NetEntityRole::Autonomous))
&& (GetRemoteNetworkRole() == NetEntityRole::Authority))
{
// We are a local client, and we are connected to server, aka AuthorityToClient
result = RpcValidationResult::HandleRpc;
}
if ((GetBoundLocalNetworkRole() == NetEntityRole::ServerSimulation)
&& (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority))
if ((GetBoundLocalNetworkRole() == NetEntityRole::Server)
&& (GetRemoteNetworkRole() == NetEntityRole::Authority))
{
// We are on a server, and we received this message from another server, therefore we should forward this to any connected clients
result = RpcValidationResult::ForwardToClient;
}
}
break;
case RpcDeliveryType::ServerAuthorityToClientAutonomous:
case RpcDeliveryType::AuthorityToAutonomous:
{
if ((GetBoundLocalNetworkRole() == NetEntityRole::ClientAutonomous)
&& (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority))
if ((GetBoundLocalNetworkRole() == NetEntityRole::Autonomous)
&& (GetRemoteNetworkRole() == NetEntityRole::Authority))
{
// We are an autonomous client, and we are connected to server, aka AuthorityToAutonomous
result = RpcValidationResult::HandleRpc;
}
if ((GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority)
&& (GetRemoteNetworkRole() == NetEntityRole::ServerSimulation))
if ((GetBoundLocalNetworkRole() == NetEntityRole::Authority)
&& (GetRemoteNetworkRole() == NetEntityRole::Server))
{
// We are on a server, and we received this message from another server, therefore we should forward this to our autonomous player
// This can occur if we've recently migrated
@@ -525,10 +525,10 @@ namespace Multiplayer
}
}
break;
case RpcDeliveryType::ClientAutonomousToServerAuthority:
case RpcDeliveryType::AutonomousToAuthority:
{
if ((GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority)
&& (GetRemoteNetworkRole() == NetEntityRole::ClientAutonomous))
if ((GetBoundLocalNetworkRole() == NetEntityRole::Authority)
&& (GetRemoteNetworkRole() == NetEntityRole::Autonomous))
{
if (IsMarkedForRemoval())
{
@@ -552,10 +552,10 @@ namespace Multiplayer
}
}
break;
case RpcDeliveryType::ServerSimulationToServerAuthority:
case RpcDeliveryType::ServerToAuthority:
{
if ((GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority)
&& (GetRemoteNetworkRole() == NetEntityRole::ServerSimulation))
if ((GetBoundLocalNetworkRole() == NetEntityRole::Authority)
&& (GetRemoteNetworkRole() == NetEntityRole::Server))
{
// if we're marked for removal, then we should forward to whomever now owns this entity
if (IsMarkedForRemoval())
@@ -583,8 +583,8 @@ namespace Multiplayer
}
if (result == RpcValidationResult::DropRpcAndDisconnect)
{
bool isLocalServer = (GetBoundLocalNetworkRole() == NetEntityRole::ServerAuthority) || (GetBoundLocalNetworkRole() == NetEntityRole::ServerSimulation);
bool isRemoteServer = (GetRemoteNetworkRole() == NetEntityRole::ServerAuthority) || (GetRemoteNetworkRole() == NetEntityRole::ServerSimulation);
bool isLocalServer = (GetBoundLocalNetworkRole() == NetEntityRole::Authority) || (GetBoundLocalNetworkRole() == NetEntityRole::Server);
bool isRemoteServer = (GetRemoteNetworkRole() == NetEntityRole::Authority) || (GetRemoteNetworkRole() == NetEntityRole::Server);
if (isLocalServer && isRemoteServer)
{
// Demote this to just a drop message, we didn't want to handle the message, but we don't want to drop the connection
@@ -680,19 +680,19 @@ namespace Multiplayer
case RpcValidationResult::ForwardToClient:
{
ScopedForwardingMessage forwarding(*this);
m_netBindComponent->GetSendServerAuthorityToClientSimulationRpcEvent().Signal(entityRpcMessage);
m_netBindComponent->GetSendAuthorityToClientRpcEvent().Signal(entityRpcMessage);
return true;
}
case RpcValidationResult::ForwardToAutonomous:
{
ScopedForwardingMessage forwarding(*this);
m_netBindComponent->GetSendServerAuthorityToClientAutonomousRpcEvent().Signal(entityRpcMessage);
m_netBindComponent->GetSendAuthorityToAutonomousRpcEvent().Signal(entityRpcMessage);
return true;
}
case RpcValidationResult::ForwardToAuthority:
{
ScopedForwardingMessage forwarding(*this);
m_netBindComponent->GetSendServerSimulationToServerAuthorityRpcEvent().Signal(entityRpcMessage);
m_netBindComponent->GetSendServerToAuthorityRpcEvent().Signal(entityRpcMessage);
return true;
}
default:
@@ -119,8 +119,8 @@ namespace Multiplayer
// Events
RpcSendEvent::Handler m_onSendRpcHandler;
RpcSendEvent::Handler m_onForwardRpcHandler;
RpcSendEvent::Handler m_onSendClientAutonomousRpcHandler;
RpcSendEvent::Handler m_onForwardClientAutonomousRpcHandler;
RpcSendEvent::Handler m_onSendAutonomousRpcHandler;
RpcSendEvent::Handler m_onForwardAutonomousRpcHandler;
EntityDirtiedEvent::Handler m_onEntityDirtiedHandler;
EntityStopEvent::Handler m_onEntityStopHandler;
AZ::ScheduledEvent m_proxyRemovalEvent;
@@ -67,7 +67,7 @@ namespace Multiplayer
void PropertyPublisher::SetRebasing()
{
AZ_Assert(m_pendingRecord.GetNetworkRole() == NetEntityRole::ClientAutonomous, "Expected to be rebasing on a ClientAutonomous entity");
AZ_Assert(m_pendingRecord.GetNetworkRole() == NetEntityRole::Autonomous, "Expected to be rebasing on a Autonomous entity");
m_replicatorState = EntityReplicatorState::Rebasing;
}
@@ -117,8 +117,8 @@ namespace Multiplayer
// This is basically an Add record, but we don't want to send back predictable values
m_sentRecords.clear();
m_netBindComponent->FillTotalReplicationRecord(m_pendingRecord);
// Don't send predictable properties back to the ClientAutonomous unless we correct them
if (m_pendingRecord.GetNetworkRole() == NetEntityRole::ClientAutonomous)
// Don't send predictable properties back to the Autonomous unless we correct them
if (m_pendingRecord.GetNetworkRole() == NetEntityRole::Autonomous)
{
m_pendingRecord.Subtract(m_netBindComponent->GetPredictableRecord());
}
@@ -144,8 +144,8 @@ namespace Multiplayer
m_pendingRecord.Append(*iter);
}
// Don't send predictable properties back to the ClientAutonomous unless we correct them
if (m_pendingRecord.GetNetworkRole() == NetEntityRole::ClientAutonomous)
// Don't send predictable properties back to the Autonomous unless we correct them
if (m_pendingRecord.GetNetworkRole() == NetEntityRole::Autonomous)
{
m_pendingRecord.Subtract(m_netBindComponent->GetPredictableRecord());
}
@@ -165,7 +165,7 @@ namespace Multiplayer
AZ_Assert(m_netBindComponent, "NetBindComponent is nullptr");
m_pendingRecord.ResetConsumedBits();
m_pendingRecord.Serialize(serializer);
m_netBindComponent->SerializeStateDeltaMessage(m_pendingRecord, serializer, ComponentSerializationType::Properties);
m_netBindComponent->SerializeStateDeltaMessage(m_pendingRecord, serializer);
return serializer.IsValid();
}
@@ -67,10 +67,10 @@ namespace Multiplayer
bool ReplicationRecord::AreAllBitsConsumed() const
{
bool ret = true;
ret &= m_authorityToClientConsumedBits == m_authorityToClientRecord.GetSize();
ret &= m_authorityToServerConsumedBits == m_authorityToServerRecord.GetSize();
ret &= m_authorityToAutonomousConsumedBits == m_authorityToAutonomousRecord.GetSize();
ret &= m_autonomousToAuthorityConsumedBits == m_autonomousToAuthorityRecord.GetSize();
ret &= m_authorityToClientConsumedBits == m_authorityToClient.GetSize();
ret &= m_authorityToServerConsumedBits == m_authorityToServer.GetSize();
ret &= m_authorityToAutonomousConsumedBits == m_authorityToAutonomous.GetSize();
ret &= m_autonomousToAuthorityConsumedBits == m_autonomousToAuthority.GetSize();
return ret;
}
@@ -86,37 +86,37 @@ namespace Multiplayer
{
ResetConsumedBits();
uint32_t recordSize = m_authorityToClientRecord.GetSize();
m_authorityToClientRecord.Clear();
m_authorityToClientRecord.Resize(recordSize);
uint32_t recordSize = m_authorityToClient.GetSize();
m_authorityToClient.Clear();
m_authorityToClient.Resize(recordSize);
recordSize = m_authorityToServerRecord.GetSize();
m_authorityToServerRecord.Clear();
m_authorityToServerRecord.Resize(recordSize);
recordSize = m_authorityToServer.GetSize();
m_authorityToServer.Clear();
m_authorityToServer.Resize(recordSize);
recordSize = m_authorityToAutonomousRecord.GetSize();
m_authorityToAutonomousRecord.Clear();
m_authorityToAutonomousRecord.Resize(recordSize);
recordSize = m_authorityToAutonomous.GetSize();
m_authorityToAutonomous.Clear();
m_authorityToAutonomous.Resize(recordSize);
recordSize = m_autonomousToAuthorityRecord.GetSize();
m_autonomousToAuthorityRecord.Clear();
m_autonomousToAuthorityRecord.Resize(recordSize);
recordSize = m_autonomousToAuthority.GetSize();
m_autonomousToAuthority.Clear();
m_autonomousToAuthority.Resize(recordSize);
}
void ReplicationRecord::Append(const ReplicationRecord &rhs)
{
m_authorityToClientRecord |= rhs.m_authorityToClientRecord;
m_authorityToServerRecord |= rhs.m_authorityToServerRecord;
m_authorityToAutonomousRecord |= rhs.m_authorityToAutonomousRecord;
m_autonomousToAuthorityRecord |= rhs.m_autonomousToAuthorityRecord;
m_authorityToClient |= rhs.m_authorityToClient;
m_authorityToServer |= rhs.m_authorityToServer;
m_authorityToAutonomous |= rhs.m_authorityToAutonomous;
m_autonomousToAuthority |= rhs.m_autonomousToAuthority;
}
void ReplicationRecord::Subtract(const ReplicationRecord &rhs)
{
m_authorityToClientRecord.Subtract(rhs.m_authorityToClientRecord);
m_authorityToServerRecord.Subtract(rhs.m_authorityToServerRecord);
m_authorityToAutonomousRecord.Subtract(rhs.m_authorityToAutonomousRecord);
m_autonomousToAuthorityRecord.Subtract(rhs.m_autonomousToAuthorityRecord);
m_authorityToClient.Subtract(rhs.m_authorityToClient);
m_authorityToServer.Subtract(rhs.m_authorityToServer);
m_authorityToAutonomous.Subtract(rhs.m_authorityToAutonomous);
m_autonomousToAuthority.Subtract(rhs.m_autonomousToAuthority);
}
bool ReplicationRecord::HasChanges() const
@@ -124,42 +124,42 @@ namespace Multiplayer
bool hasChanges(false);
if (ContainsAuthorityToClientBits())
{
hasChanges = hasChanges ? hasChanges : m_authorityToClientRecord.AnySet();
hasChanges = hasChanges ? hasChanges : m_authorityToClient.AnySet();
}
if (ContainsAuthorityToServerBits())
{
hasChanges = hasChanges ? hasChanges : m_authorityToServerRecord.AnySet();
hasChanges = hasChanges ? hasChanges : m_authorityToServer.AnySet();
}
if (ContainsAuthorityToAutonomousBits())
{
hasChanges = hasChanges ? hasChanges : m_authorityToAutonomousRecord.AnySet();
hasChanges = hasChanges ? hasChanges : m_authorityToAutonomous.AnySet();
}
if (ContainsAutonomousToAuthorityBits())
{
hasChanges = hasChanges ? hasChanges : m_autonomousToAuthorityRecord.AnySet();
hasChanges = hasChanges ? hasChanges : m_autonomousToAuthority.AnySet();
}
return hasChanges;
}
bool ReplicationRecord::Serialize(AzNetworking::ISerializer& a_Serializer)
bool ReplicationRecord::Serialize(AzNetworking::ISerializer& serializer)
{
if (ContainsAuthorityToClientBits())
{
a_Serializer.Serialize(m_authorityToClientRecord, "ServerToClientsRecord");
serializer.Serialize(m_authorityToClient, "ServerToClientsRecord");
}
if (ContainsAuthorityToServerBits())
{
a_Serializer.Serialize(m_authorityToServerRecord, "ServerToServersRecord");
serializer.Serialize(m_authorityToServer, "ServerToServersRecord");
}
if (ContainsAuthorityToAutonomousBits())
{
a_Serializer.Serialize(m_authorityToAutonomousRecord, "ServerToClientAutonomousRecord");
serializer.Serialize(m_authorityToAutonomous, "ServerToAutonomousRecord");
}
if (ContainsAutonomousToAuthorityBits())
{
a_Serializer.Serialize(m_autonomousToAuthorityRecord, "ClientToServersRecord");
serializer.Serialize(m_autonomousToAuthority, "ClientToServersRecord");
}
return a_Serializer.IsValid();
return serializer.IsValid();
}
void ReplicationRecord::ConsumeAuthorityToClientBits(uint32_t consumedBits)
@@ -196,46 +196,46 @@ namespace Multiplayer
bool ReplicationRecord::ContainsAuthorityToClientBits() const
{
return (m_netEntityRole != NetEntityRole::ServerAuthority)
return (m_netEntityRole != NetEntityRole::Authority)
|| (m_netEntityRole == NetEntityRole::InvalidRole);
}
bool ReplicationRecord::ContainsAuthorityToServerBits() const
{
return (m_netEntityRole == NetEntityRole::ServerSimulation)
return (m_netEntityRole == NetEntityRole::Server)
|| (m_netEntityRole == NetEntityRole::InvalidRole);
}
bool ReplicationRecord::ContainsAuthorityToAutonomousBits() const
{
return (m_netEntityRole == NetEntityRole::ClientAutonomous || m_netEntityRole == NetEntityRole::ServerSimulation)
return (m_netEntityRole == NetEntityRole::Autonomous || m_netEntityRole == NetEntityRole::Server)
|| (m_netEntityRole == NetEntityRole::InvalidRole);
}
bool ReplicationRecord::ContainsAutonomousToAuthorityBits() const
{
return (m_netEntityRole == NetEntityRole::ServerAuthority)
return (m_netEntityRole == NetEntityRole::Authority)
|| (m_netEntityRole == NetEntityRole::InvalidRole);
}
uint32_t ReplicationRecord::GetRemainingAuthorityToClientBits() const
{
return m_authorityToClientConsumedBits < m_authorityToClientRecord.GetValidBitCount() ? m_authorityToClientRecord.GetValidBitCount() - m_authorityToClientConsumedBits : 0;
return m_authorityToClientConsumedBits < m_authorityToClient.GetValidBitCount() ? m_authorityToClient.GetValidBitCount() - m_authorityToClientConsumedBits : 0;
}
uint32_t ReplicationRecord::GetRemainingAuthorityToServerBits() const
{
return m_authorityToServerConsumedBits < m_authorityToServerRecord.GetValidBitCount() ? m_authorityToServerRecord.GetValidBitCount() - m_authorityToServerConsumedBits : 0;
return m_authorityToServerConsumedBits < m_authorityToServer.GetValidBitCount() ? m_authorityToServer.GetValidBitCount() - m_authorityToServerConsumedBits : 0;
}
uint32_t ReplicationRecord::GetRemainingAuthorityToAutonomousBits() const
{
return m_authorityToAutonomousConsumedBits < m_authorityToAutonomousRecord.GetValidBitCount() ? m_authorityToAutonomousRecord.GetValidBitCount() - m_authorityToAutonomousConsumedBits : 0;
return m_authorityToAutonomousConsumedBits < m_authorityToAutonomous.GetValidBitCount() ? m_authorityToAutonomous.GetValidBitCount() - m_authorityToAutonomousConsumedBits : 0;
}
uint32_t ReplicationRecord::GetRemainingAutonomousToAuthorityBits() const
{
return m_autonomousToAuthorityConsumedBits < m_autonomousToAuthorityRecord.GetValidBitCount() ? m_autonomousToAuthorityRecord.GetValidBitCount() - m_autonomousToAuthorityConsumedBits : 0;
return m_autonomousToAuthorityConsumedBits < m_autonomousToAuthority.GetValidBitCount() ? m_autonomousToAuthority.GetValidBitCount() - m_autonomousToAuthorityConsumedBits : 0;
}
ReplicationRecordStats ReplicationRecord::GetStats() const
@@ -79,10 +79,10 @@ namespace Multiplayer
ReplicationRecordStats GetStats() const;
using RecordBitset = AzNetworking::FixedSizeVectorBitset<MaxRecordBits>;
RecordBitset m_authorityToClientRecord;
RecordBitset m_authorityToServerRecord;
RecordBitset m_authorityToAutonomousRecord;
RecordBitset m_autonomousToAuthorityRecord;
RecordBitset m_authorityToClient;
RecordBitset m_authorityToServer;
RecordBitset m_authorityToAutonomous;
RecordBitset m_autonomousToAuthority;
uint32_t m_authorityToClientConsumedBits = 0;
uint32_t m_authorityToServerConsumedBits = 0;