Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Queue RPCs by Worker_EntityId #1138

Merged
merged 5 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,8 @@ void USpatialReceiver::HandleRPC(const Worker_ComponentUpdateOp& Op)
UFunction* Function = ClassInfo.RPCs[Payload.Index];
const FRPCInfo& RPCInfo = ClassInfoManager->GetRPCInfo(TargetObject, Function);

if (!IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef, RPCInfo.Type)
&& !IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef, ESchemaComponentType::SCHEMA_Invalid))
if (!IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef.Entity, RPCInfo.Type)
&& !IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef.Entity, ESchemaComponentType::SCHEMA_Invalid))
{
// Apply if possible, queue otherwise
if (ApplyRPC(*Params))
Expand Down Expand Up @@ -1642,8 +1642,8 @@ void USpatialReceiver::ProcessQueuedActorRPCsOnEntityCreation(AActor* Actor, RPC
const FUnrealObjectRef ObjectRef = PackageMap->GetUnrealObjectRefFromObject(Actor);
check(ObjectRef != FUnrealObjectRef::UNRESOLVED_OBJECT_REF);

if (!IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef, RPCInfo.Type)
&& !IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef, ESchemaComponentType::SCHEMA_Invalid))
if (!IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef.Entity, RPCInfo.Type)
&& !IncomingRPCs.ObjectHasRPCsQueuedOfType(ObjectRef.Entity, ESchemaComponentType::SCHEMA_Invalid))
{
if (ApplyRPC(Actor, Function, RPC, FString()))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ void USpatialSender::ProcessRPC(FPendingRPCParamsPtr Params)
const FRPCInfo& RPCInfo = ClassInfoManager->GetRPCInfo(TargetObject.Get(), Function);

bool bRPCProcessed = false;
if (!OutgoingRPCs.ObjectHasRPCsQueuedOfType(Params->ObjectRef, RPCInfo.Type))
if (!OutgoingRPCs.ObjectHasRPCsQueuedOfType(Params->ObjectRef.Entity, RPCInfo.Type))
{
if (SendRPC(*Params))
{
Expand Down
10 changes: 4 additions & 6 deletions SpatialGDK/Source/SpatialGDK/Private/Utils/RPCContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FPendingRPCParams::FPendingRPCParams(const FUnrealObjectRef& InTargetObjectRef,

void FRPCContainer::QueueRPC(FPendingRPCParamsPtr Params, ESchemaComponentType Type)
{
FArrayOfParams& ArrayOfParams = QueuedRPCs.FindOrAdd(Type).FindOrAdd(Params->ObjectRef);
FArrayOfParams& ArrayOfParams = QueuedRPCs.FindOrAdd(Type).FindOrAdd(Params->ObjectRef.Entity);
ArrayOfParams.Push(MoveTemp(Params));
}

Expand Down Expand Up @@ -54,13 +54,11 @@ void FRPCContainer::ProcessRPCs(const FProcessRPCDelegate& FunctionToApply)
}
}

bool FRPCContainer::ObjectHasRPCsQueuedOfType(const FUnrealObjectRef& TargetObjectRef, ESchemaComponentType Type) const
bool FRPCContainer::ObjectHasRPCsQueuedOfType(const Worker_EntityId& EntityId, ESchemaComponentType Type) const
{
const FRPCMap* MapOfQueues = QueuedRPCs.Find(Type);
if(MapOfQueues)
if(const FRPCMap* MapOfQueues = QueuedRPCs.Find(Type))
{
const FArrayOfParams* RPCList = MapOfQueues->Find(TargetObjectRef);
if(RPCList)
if(const FArrayOfParams* RPCList = MapOfQueues->Find(EntityId))
{
return (RPCList->Num() > 0);
}
Expand Down
4 changes: 2 additions & 2 deletions SpatialGDK/Source/SpatialGDK/Public/Utils/RPCContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class FRPCContainer
public:
void QueueRPC(FPendingRPCParamsPtr Params, ESchemaComponentType Type);
void ProcessRPCs(const FProcessRPCDelegate& FunctionToApply);
bool ObjectHasRPCsQueuedOfType(const FUnrealObjectRef& TargetObjectRef, ESchemaComponentType Type) const;
bool ObjectHasRPCsQueuedOfType(const Worker_EntityId& EntityId, ESchemaComponentType Type) const;
aleximprobable marked this conversation as resolved.
Show resolved Hide resolved

private:
using FArrayOfParams = TArray<FPendingRPCParamsPtr>;
using FRPCMap = TMap<FUnrealObjectRef, FArrayOfParams>;
using FRPCMap = TMap<Worker_EntityId_Key, FArrayOfParams>;
using RPCContainerType = TMap<ESchemaComponentType, FRPCMap>;

void ProcessRPCs(const FProcessRPCDelegate& FunctionToApply, FArrayOfParams& RPCList);
Expand Down