Addressing PR feedback

This commit is contained in:
karlberg
2021-04-27 16:03:39 -07:00
parent 138b10c902
commit 2fc710d73b
32 changed files with 307 additions and 197 deletions
@@ -21,6 +21,7 @@
#include <Source/NetworkEntity/INetworkEntityManager.h>
#include <Source/Components/NetBindComponent.h>
#include <Source/AutoGen/Multiplayer.AutoPackets.h>
#include <Include/IMultiplayer.h>
#include <AzNetworking/ConnectionLayer/IConnection.h>
#include <AzNetworking/ConnectionLayer/IConnectionListener.h>
#include <AzNetworking/PacketLayer/IPacketHeader.h>
@@ -825,11 +826,12 @@ namespace Multiplayer
{
if (entityReplicator == nullptr)
{
IMultiplayer* multiplayer = AZ::Interface<IMultiplayer>::Get();
AZLOG_INFO
(
"EntityReplicationManager: Dropping remote RPC message for component %u of rpc type %d, entityId %u has already been deleted",
aznumeric_cast<uint32_t>(message.GetComponentId()),
message.GetRpcMessageType(),
"EntityReplicationManager: Dropping remote RPC message for component %s of rpc index %s, entityId %u has already been deleted",
multiplayer->GetComponentName(message.GetComponentId()),
multiplayer->GetComponentRpcName(message.GetComponentId(), message.GetRpcIndex()),
message.GetEntityId()
);
return false;
@@ -449,7 +449,7 @@ namespace Multiplayer
{
// Received rpc metrics, log rpc sent, number of bytes, and the componentId/rpcId for bandwidth metrics
MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats();
stats.RecordRpcSent(static_cast<uint16_t>(entityRpcMessage.GetComponentId()), entityRpcMessage.GetRpcMessageType(), entityRpcMessage.GetEstimatedSerializeSize());
stats.RecordRpcSent(entityRpcMessage.GetComponentId(), entityRpcMessage.GetRpcIndex(), entityRpcMessage.GetEstimatedSerializeSize());
m_replicationManager.AddDeferredRpcMessage(entityRpcMessage);
}
@@ -603,7 +603,7 @@ namespace Multiplayer
aznumeric_cast<uint32_t>(GetRemoteNetworkRole()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcMessageType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcIndex()),
entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false",
IsMarkedForRemoval() ? "true" : "false"
);
@@ -620,7 +620,7 @@ namespace Multiplayer
aznumeric_cast<uint32_t>(GetRemoteNetworkRole()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcMessageType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcIndex()),
entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false",
IsMarkedForRemoval() ? "true" : "false"
);
@@ -632,7 +632,7 @@ namespace Multiplayer
{
// Received rpc metrics, log rpc received, time spent, number of bytes, and the componentId/rpcId for bandwidth metrics
MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats();
stats.RecordRpcReceived(static_cast<uint16_t>(entityRpcMessage.GetComponentId()), entityRpcMessage.GetRpcMessageType(), entityRpcMessage.GetEstimatedSerializeSize());
stats.RecordRpcReceived(entityRpcMessage.GetComponentId(), entityRpcMessage.GetRpcIndex(), entityRpcMessage.GetEstimatedSerializeSize());
if (!m_netBindComponent)
{
@@ -644,7 +644,7 @@ namespace Multiplayer
aznumeric_cast<uint32_t>(GetRemoteNetworkRole()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcMessageType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcIndex()),
entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false",
IsMarkedForRemoval() ? "true" : "false"
);
@@ -15,7 +15,7 @@
#include <AzNetworking/DataStructures/FixedSizeVectorBitset.h>
#include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/Utilities/NetworkCommon.h>
#include <Source/MultiplayerTypes.h>
#include <Include/MultiplayerTypes.h>
namespace Multiplayer
{
@@ -12,7 +12,7 @@
#pragma once
#include <Source/MultiplayerTypes.h>
#include <Include/MultiplayerTypes.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/EBus/Event.h>
@@ -13,7 +13,7 @@
#pragma once
#include <AzCore/Component/Entity.h>
#include <Source/MultiplayerTypes.h>
#include <Include/MultiplayerTypes.h>
namespace Multiplayer
{
@@ -21,7 +21,7 @@ namespace Multiplayer
: m_rpcDeliveryType(rhs.m_rpcDeliveryType)
, m_entityId(rhs.m_entityId)
, m_componentId(rhs.m_componentId)
, m_rpcMessageType(rhs.m_rpcMessageType)
, m_rpcIndex(rhs.m_rpcIndex)
, m_data(AZStd::move(rhs.m_data))
, m_isReliable(rhs.m_isReliable)
{
@@ -32,7 +32,7 @@ namespace Multiplayer
: m_rpcDeliveryType(rhs.m_rpcDeliveryType)
, m_entityId(rhs.m_entityId)
, m_componentId(rhs.m_componentId)
, m_rpcMessageType(rhs.m_rpcMessageType)
, m_rpcIndex(rhs.m_rpcIndex)
, m_isReliable(rhs.m_isReliable)
{
if (rhs.m_data != nullptr)
@@ -42,11 +42,11 @@ namespace Multiplayer
}
}
NetworkEntityRpcMessage::NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, uint16_t rpcMessageType, ReliabilityType isReliable)
NetworkEntityRpcMessage::NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, RpcIndex rpcIndex, ReliabilityType isReliable)
: m_rpcDeliveryType(rpcDeliveryType)
, m_entityId(entityId)
, m_componentId(componentId)
, m_rpcMessageType(rpcMessageType)
, m_rpcIndex(rpcIndex)
, m_isReliable(isReliable)
{
;
@@ -57,7 +57,7 @@ namespace Multiplayer
m_rpcDeliveryType = rhs.m_rpcDeliveryType;
m_entityId = rhs.m_entityId;
m_componentId = rhs.m_componentId;
m_rpcMessageType = rhs.m_rpcMessageType;
m_rpcIndex = rhs.m_rpcIndex;
m_isReliable = rhs.m_isReliable;
m_data = AZStd::move(rhs.m_data);
return *this;
@@ -68,7 +68,7 @@ namespace Multiplayer
m_rpcDeliveryType = rhs.m_rpcDeliveryType;
m_entityId = rhs.m_entityId;
m_componentId = rhs.m_componentId;
m_rpcMessageType = rhs.m_rpcMessageType;
m_rpcIndex = rhs.m_rpcIndex;
m_isReliable = rhs.m_isReliable;
if (rhs.m_data != nullptr)
{
@@ -85,7 +85,7 @@ namespace Multiplayer
return ((m_rpcDeliveryType == rhs.m_rpcDeliveryType)
&& (m_entityId == rhs.m_entityId)
&& (m_componentId == rhs.m_componentId)
&& (m_rpcMessageType == rhs.m_rpcMessageType));
&& (m_rpcIndex == rhs.m_rpcIndex));
}
bool NetworkEntityRpcMessage::operator !=(const NetworkEntityRpcMessage& rhs) const
@@ -101,7 +101,7 @@ namespace Multiplayer
+ sizeof(uint16_t);
// 2-byte size header + the actual blob payload itself
const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(uint16_t) + m_data->GetSize() : 0;
const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(RpcIndex) + m_data->GetSize() : 0;
// No sliceId, remote replicator already exists so we don't need to know what type of entity this is
return sizeOfFields + sizeOfBlob;
@@ -127,9 +127,9 @@ namespace Multiplayer
return m_componentId;
}
uint16_t NetworkEntityRpcMessage::GetRpcMessageType() const
RpcIndex NetworkEntityRpcMessage::GetRpcIndex() const
{
return m_rpcMessageType;
return m_rpcIndex;
}
bool NetworkEntityRpcMessage::SetRpcParams(IRpcParamStruct& params)
@@ -167,7 +167,7 @@ namespace Multiplayer
serializer.Serialize(m_rpcDeliveryType, "RpcDeliveryType");
serializer.Serialize(m_entityId, "EntityId");
serializer.Serialize(m_componentId, "ComponentId");
serializer.Serialize(m_rpcMessageType, "RpcMessageType");
serializer.Serialize(m_rpcIndex, "RpcIndex");
// m_data should never be nullptr, it contains serialized data for our Rpc params struct
if (m_data == nullptr)
@@ -14,7 +14,7 @@
#include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/DataStructures/ByteBuffer.h>
#include <Source/MultiplayerTypes.h>
#include <Include/MultiplayerTypes.h>
namespace Multiplayer
{
@@ -35,12 +35,12 @@ namespace Multiplayer
NetworkEntityRpcMessage(const NetworkEntityRpcMessage& rhs);
//! Fill explicit constructor.
//! @param rpcDeliveryType the delivery type (origin and target) for this RPC
//! @param entityId the networked entityId of the entity handling this RPC
//! @param componentType the networked componentId of the component handling this RPC
//! @param rpcMessageType the component defined RPC type, so the component knows which RPC this message corresponds to
//! @param isReliable whether or not this RPC should be sent reliably
explicit NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, uint16_t rpcMessageType, ReliabilityType isReliable);
//! @param rpcDeliveryType the delivery type (origin and target) for this rpc
//! @param entityId the networked entityId of the entity handling this rpc
//! @param componentType the networked componentId of the component handling this rpc
//! @param rpcIndex the component defined rpc index, so the component knows which rpc this message corresponds to
//! @param isReliable whether or not this rpc should be sent reliably
explicit NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, RpcIndex rpcIndex, ReliabilityType isReliable);
NetworkEntityRpcMessage& operator =(NetworkEntityRpcMessage&& rhs);
NetworkEntityRpcMessage& operator =(const NetworkEntityRpcMessage& rhs);
@@ -67,9 +67,9 @@ namespace Multiplayer
//! @return the current value of EntityComponentType
NetComponentId GetComponentId() const;
//! Gets the current value of RpcMessageType.
//! @return the current value of RpcMessageType
uint16_t GetRpcMessageType() const;
//! Gets the current value of RpcIndex.
//! @return the current value of RpcIndex
RpcIndex GetRpcIndex() const;
//! Writes the data contained inside a_Params to this NetworkEntityRpcMessage's blob buffer.
//! @param params the parameters to save inside this NetworkEntityRpcMessage instance
@@ -98,7 +98,7 @@ namespace Multiplayer
RpcDeliveryType m_rpcDeliveryType = RpcDeliveryType::None;
NetEntityId m_entityId = InvalidNetEntityId;
NetComponentId m_componentId = InvalidNetComponentId;
uint16_t m_rpcMessageType = 0;
RpcIndex m_rpcIndex = RpcIndex{ 0 };
// Only allocated if we actually have data
// This is to prevent blowing out stack memory if we declare an array of these EntityUpdateMessages
@@ -12,7 +12,7 @@
#pragma once
#include <Source/MultiplayerTypes.h>
#include <Include/MultiplayerTypes.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/Component/Entity.h>
@@ -131,7 +131,7 @@ namespace Multiplayer
}
// 2-byte size header + the actual blob payload itself
const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(uint16_t) + m_data->GetSize() : 0;
const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(PropertyIndex) + m_data->GetSize() : 0;
if (m_hasValidPrefabId)
{
@@ -15,7 +15,7 @@
#include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/DataStructures/ByteBuffer.h>
#include <AzCore/Name/Name.h>
#include <Source/MultiplayerTypes.h>
#include <Include/MultiplayerTypes.h>
namespace Multiplayer
{