Merging latest main
This commit is contained in:
+18
-19
@@ -25,6 +25,7 @@
|
||||
#include <AzNetworking/PacketLayer/IPacketHeader.h>
|
||||
#include <AzNetworking/Serialization/NetworkInputSerializer.h>
|
||||
#include <AzNetworking/Serialization/NetworkOutputSerializer.h>
|
||||
#include <AzNetworking/Serialization/TrackChangedSerializer.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
@@ -127,9 +128,9 @@ namespace Multiplayer
|
||||
MultiplayerPackets::EntityUpdates entityUpdatePacket;
|
||||
entityUpdatePacket.SetHostTimeMs(serverGameTimeMs);
|
||||
// Serialize everything
|
||||
for (auto it = toSendList.begin(); it != toSendList.end();)
|
||||
while (!toSendList.empty())
|
||||
{
|
||||
EntityReplicator* replicator = *it;
|
||||
EntityReplicator* replicator = toSendList.front();
|
||||
NetworkEntityUpdateMessage updateMessage(replicator->GenerateUpdatePacket());
|
||||
|
||||
const uint32_t nextMessageSize = updateMessage.GetEstimatedSerializeSize();
|
||||
@@ -145,15 +146,15 @@ namespace Multiplayer
|
||||
|
||||
pendingPacketSize += nextMessageSize;
|
||||
entityUpdatePacket.ModifyEntityMessages().push_back(updateMessage);
|
||||
replicatorUpdatedList.push_back(*it);
|
||||
it = toSendList.erase(it);
|
||||
replicatorUpdatedList.push_back(replicator);
|
||||
toSendList.pop_front();
|
||||
|
||||
if (largeEntityDetected)
|
||||
{
|
||||
AZLOG_WARN("\n\n*******************************");
|
||||
AZLOG_WARN
|
||||
(
|
||||
"Serializing Extremely Large Entity (%u) - MaxPayload: %d NeededSize %d",
|
||||
"Serializing extremely large entity (%u) - MaxPayload: %d NeededSize %d",
|
||||
aznumeric_cast<uint32_t>(replicator->GetEntityHandle().GetNetEntityId()),
|
||||
maxPayloadSize,
|
||||
nextMessageSize
|
||||
@@ -174,16 +175,16 @@ namespace Multiplayer
|
||||
|
||||
EntityReplicationManager::EntityReplicatorList EntityReplicationManager::GenerateEntityUpdateList()
|
||||
{
|
||||
if (m_replicationWindow == nullptr)
|
||||
{
|
||||
return EntityReplicatorList();
|
||||
}
|
||||
|
||||
// Generate a list of all our entities that need updates
|
||||
EntityReplicatorList autonomousReplicators;
|
||||
autonomousReplicators.reserve(m_replicatorsPendingSend.size());
|
||||
EntityReplicatorList proxyReplicators;
|
||||
proxyReplicators.reserve(m_replicatorsPendingSend.size());
|
||||
EntityReplicatorList toSendList;
|
||||
|
||||
uint32_t elementsAdded = 0;
|
||||
for (auto iter = m_replicatorsPendingSend.begin();
|
||||
iter != m_replicatorsPendingSend.end()
|
||||
&& elementsAdded < m_replicationWindow->GetMaxEntityReplicatorSendCount();)
|
||||
for (auto iter = m_replicatorsPendingSend.begin(); iter != m_replicatorsPendingSend.end() && elementsAdded < m_replicationWindow->GetMaxEntityReplicatorSendCount(); )
|
||||
{
|
||||
EntityReplicator* replicator = GetEntityReplicator(*iter);
|
||||
bool clearPendingSend = true;
|
||||
@@ -219,13 +220,13 @@ namespace Multiplayer
|
||||
|
||||
if (replicator->GetRemoteNetworkRole() == NetEntityRole::Autonomous)
|
||||
{
|
||||
autonomousReplicators.push_back(replicator);
|
||||
toSendList.push_back(replicator);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (elementsAdded < m_replicationWindow->GetMaxEntityReplicatorSendCount())
|
||||
{
|
||||
proxyReplicators.push_back(replicator);
|
||||
toSendList.push_back(replicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,9 +245,6 @@ namespace Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
EntityReplicatorList toSendList;
|
||||
toSendList.swap(autonomousReplicators);
|
||||
toSendList.insert(toSendList.end(), proxyReplicators.begin(), proxyReplicators.end());
|
||||
return toSendList;
|
||||
}
|
||||
|
||||
@@ -544,6 +542,7 @@ namespace Multiplayer
|
||||
// Create an entity if we don't have one
|
||||
if (createEntity)
|
||||
{
|
||||
// @pereslav
|
||||
//replicatorEntity = GetNetworkEntityManager()->CreateSingleEntityImmediateInternal(prefabEntityId, EntitySpawnType::Replicate, AutoActivate::DoNotActivate, netEntityId, localNetworkRole, AZ::Transform::Identity());
|
||||
INetworkEntityManager::EntityList entityList = GetNetworkEntityManager()->CreateEntitiesImmediate(
|
||||
prefabEntityId, netEntityId, localNetworkRole,
|
||||
@@ -775,7 +774,7 @@ namespace Multiplayer
|
||||
return HandleEntityDeleteMessage(entityReplicator, packetHeader, updateMessage);
|
||||
}
|
||||
|
||||
AzNetworking::NetworkOutputSerializer outputSerializer(updateMessage.GetData()->GetBuffer(), updateMessage.GetData()->GetSize());
|
||||
AzNetworking::TrackChangedSerializer<AzNetworking::NetworkOutputSerializer> outputSerializer(updateMessage.GetData()->GetBuffer(), updateMessage.GetData()->GetSize());
|
||||
|
||||
PrefabEntityId prefabEntityId;
|
||||
if (updateMessage.GetHasValidPrefabId())
|
||||
@@ -1135,7 +1134,7 @@ namespace Multiplayer
|
||||
{
|
||||
if (message.GetPropertyUpdateData().GetSize() > 0)
|
||||
{
|
||||
AzNetworking::NetworkOutputSerializer outputSerializer(message.ModifyPropertyUpdateData().GetBuffer(), message.ModifyPropertyUpdateData().GetSize());
|
||||
AzNetworking::TrackChangedSerializer<AzNetworking::NetworkOutputSerializer> outputSerializer(message.ModifyPropertyUpdateData().GetBuffer(), message.ModifyPropertyUpdateData().GetSize());
|
||||
if (!HandlePropertyChangeMessage
|
||||
(
|
||||
replicator,
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@
|
||||
#include <AzNetworking/PacketLayer/IPacketHeader.h>
|
||||
#include <AzCore/std/containers/map.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/containers/deque.h>
|
||||
#include <AzCore/std/limits.h>
|
||||
#include <AzCore/EBus/Event.h>
|
||||
#include <AzCore/EBus/ScheduledEvent.h>
|
||||
@@ -114,7 +115,7 @@ namespace Multiplayer
|
||||
using RpcMessages = AZStd::list<NetworkEntityRpcMessage>;
|
||||
bool DispatchOrphanedRpc(NetworkEntityRpcMessage& message, EntityReplicator* entityReplicator);
|
||||
|
||||
using EntityReplicatorList = AZStd::vector<EntityReplicator*>;
|
||||
using EntityReplicatorList = AZStd::deque<EntityReplicator*>;
|
||||
EntityReplicatorList GenerateEntityUpdateList();
|
||||
|
||||
void SendEntityUpdatesPacketHelper(AZ::TimeMs serverGameTimeMs, EntityReplicatorList& toSendList, uint32_t maxPayloadSize, AzNetworking::IConnection& connection);
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace Multiplayer
|
||||
AZ_Assert(netBindComponent, "No Multiplayer::NetBindComponent");
|
||||
|
||||
bool isAuthority = (GetBoundLocalNetworkRole() == NetEntityRole::Authority)
|
||||
&& (GetBoundLocalNetworkRole() == netBindComponent->GetNetEntityRole());
|
||||
&& (GetBoundLocalNetworkRole() == netBindComponent->GetNetEntityRole());
|
||||
bool isClient = GetRemoteNetworkRole() == NetEntityRole::Client;
|
||||
bool isAutonomous = GetBoundLocalNetworkRole() == NetEntityRole::Autonomous;
|
||||
if (isAuthority || isClient || isAutonomous)
|
||||
@@ -311,9 +311,9 @@ namespace Multiplayer
|
||||
{
|
||||
bool ret(false);
|
||||
bool isServer = (GetBoundLocalNetworkRole() == NetEntityRole::Server)
|
||||
&& (GetRemoteNetworkRole() == NetEntityRole::Authority);
|
||||
&& (GetRemoteNetworkRole() == NetEntityRole::Authority);
|
||||
bool isClient = (GetBoundLocalNetworkRole() == NetEntityRole::Client)
|
||||
|| (GetBoundLocalNetworkRole() == NetEntityRole::Autonomous);
|
||||
|| (GetBoundLocalNetworkRole() == NetEntityRole::Autonomous);
|
||||
if (isServer || isClient)
|
||||
{
|
||||
ret = true;
|
||||
|
||||
Reference in New Issue
Block a user