Files
o3de/Code/Framework/GridMate/GridMate/Replica/BasicHostChunkDescriptor.h
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

40 lines
1.3 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <GridMate/Replica/ReplicaChunkDescriptor.h>
#include <GridMate/Replica/ReplicaMgr.h>
namespace GridMate
{
/**
* BasicHostChunkDescriptor implements a helper descriptor
* that prevents chunk proxies from being created on the host.
* The idea is to prevent a malicious client from creating
* (and owning) chunk types that should always be authoritative
* on the host.
*/
template<typename ReplicaChunkType>
class BasicHostChunkDescriptor
: public DefaultReplicaChunkDescriptor<ReplicaChunkType>
{
public:
ReplicaChunkBase* CreateFromStream(UnmarshalContext& mc) override
{
ReplicaChunkBase* replicaChunk = nullptr;
AZ_Assert(!mc.m_rm->IsSyncHost(), "Replicas of type %s can only be owned by the host!", DefaultReplicaChunkDescriptor<ReplicaChunkType>::GetChunkName());
if (!mc.m_rm->IsSyncHost())
{
replicaChunk = aznew ReplicaChunkType;
}
return replicaChunk;
}
};
}