SPEC-7469 Fixed EditorServerInfo packet serialization
This commit is contained in:
@@ -205,6 +205,7 @@ namespace AzNetworking
|
||||
NetworkInputSerializer serializer(buffer.GetBuffer(), buffer.GetCapacity());
|
||||
if (!const_cast<IPacket&>(packet).Serialize(serializer))
|
||||
{
|
||||
AZ_Assert(false, "SendReliablePacket: Unable to serialize packet [Type: %d]", packet.GetPacketType());
|
||||
return false;
|
||||
}
|
||||
buffer.Resize(serializer.GetSize());
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Multiplayer/IMultiplayer.h>
|
||||
#include <Multiplayer/MultiplayerConstants.h>
|
||||
#include <Editor/MultiplayerEditorConnection.h>
|
||||
#include <Editor/MultiplayerEditorUtils.h>
|
||||
#include <Source/AutoGen/AutoComponentTypes.h>
|
||||
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
@@ -58,7 +59,7 @@ namespace Multiplayer
|
||||
if (!packet.GetLastUpdate())
|
||||
{
|
||||
// More packets are expected, flush this to the buffer
|
||||
m_byteStream.Write(TcpPacketEncodingBuffer::GetCapacity(), reinterpret_cast<void*>(packet.ModifyAssetData().GetBuffer()));
|
||||
m_byteStream.Write(GetMaxEditorServerInitSize(), reinterpret_cast<void*>(packet.ModifyAssetData().GetBuffer()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,6 +81,11 @@ namespace Multiplayer
|
||||
|
||||
size_t assetSize = m_byteStream.GetCurPos();
|
||||
AZ::Data::AssetData* assetDatum = AZ::Utils::LoadObjectFromStream<AZ::Data::AssetData>(m_byteStream, nullptr);
|
||||
if (!assetDatum)
|
||||
{
|
||||
AZLOG_ERROR("EditorServerInit packet contains no asset data. Asset: %s", assetHint.c_str());
|
||||
return false;
|
||||
}
|
||||
assetSize = m_byteStream.GetCurPos() - assetSize;
|
||||
AZ::Data::Asset<AZ::Data::AssetData> asset = AZ::Data::Asset<AZ::Data::AssetData>(assetId, assetDatum, AZ::Data::AssetLoadBehavior::NoLoad);
|
||||
asset.SetHint(assetHint);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <MultiplayerSystemComponent.h>
|
||||
#include <Editor/MultiplayerEditorSystemComponent.h>
|
||||
#include <Editor/MultiplayerEditorUtils.h>
|
||||
#include <Source/AutoGen/Multiplayer.AutoPackets.h>
|
||||
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
@@ -214,7 +215,7 @@ namespace Multiplayer
|
||||
AzNetworking::TcpPacketEncodingBuffer& outBuffer = packet.ModifyAssetData();
|
||||
|
||||
// Size the packet's buffer appropriately
|
||||
size_t readSize = TcpPacketEncodingBuffer::GetCapacity();
|
||||
size_t readSize = GetMaxEditorServerInitSize();
|
||||
size_t byteStreamSize = byteStream.GetLength() - byteStream.GetCurPos();
|
||||
if (byteStreamSize < readSize)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzNetworking/DataStructures/ByteBuffer.h>
|
||||
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
static constexpr size_t GetMaxEditorServerInitSize()
|
||||
{
|
||||
constexpr size_t totalCapacity = AzNetworking::TcpPacketEncodingBuffer::GetCapacity();
|
||||
constexpr size_t packetOverhead = sizeof(bool) + 2 * sizeof(uint16_t); // m_lastUpdate + m_assetBuffer
|
||||
static_assert(totalCapacity > packetOverhead);
|
||||
return totalCapacity - packetOverhead;
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@ set(FILES
|
||||
Source/ConnectionData/ServerToClientConnectionData.inl
|
||||
Source/Editor/MultiplayerEditorConnection.cpp
|
||||
Source/Editor/MultiplayerEditorConnection.h
|
||||
Source/Editor/MultiplayerEditorUtils.h
|
||||
Source/EntityDomains/FullOwnershipEntityDomain.cpp
|
||||
Source/EntityDomains/FullOwnershipEntityDomain.h
|
||||
Source/NetworkEntity/EntityReplication/EntityReplicationManager.cpp
|
||||
|
||||
Reference in New Issue
Block a user