Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
4.19 compatibility (UNR-127) (#75)
Browse files Browse the repository at this point in the history
* cpp changes for 4.19 compatibility

* Fix interop type signature for array arguments, don't generate type bindings for them

* Fix issue with UEBuildConfiguration.bBuildEditor flag in Build.cs

* Don't compare type against a string

* Change engine branch reference in README

* Style
  • Loading branch information
Dave Dolben authored and girayimprobable committed Apr 18, 2018
1 parent 59d7d9b commit 40bbfbe
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,15 @@ void GenerateFunction_RPCSendCommand(FCodeWriter& SourceWriter, UClass* Class, c
SourceWriter.Print("FFrame& Stack = *RPCFrame;");
for (TFieldIterator<UProperty> Param(RPC->Function); Param; ++Param)
{
// TODO: UNR-152
if (Param->IsA(UArrayProperty::StaticClass()))
{
FString ParamTypeName = GetFullCPPName((*Param)->GetClass());
FString ParamName = (*Param)->GetName();
SourceWriter.Printf("// UNSUPPORTED TArray parameters (%s %s)", *ParamTypeName, *ParamName);
continue;
}

SourceWriter.Print(*GenerateFFramePropertyReader(*Param));
}
SourceWriter.PrintNewLine();
Expand All @@ -1563,6 +1572,12 @@ void GenerateFunction_RPCSendCommand(FCodeWriter& SourceWriter, UClass* Class, c
CapturedArguments.Add(TEXT("TargetObject"));
for (TFieldIterator<UProperty> Param(RPC->Function); Param; ++Param)
{
// TODO: UNR-152
if (Param->IsA(UArrayProperty::StaticClass()))
{
continue;
}

CapturedArguments.Add((*Param)->GetName());
}
SourceWriter.Printf("auto Sender = [this, Connection, %s]() mutable -> FRPCCommandRequestResult", *FString::Join(CapturedArguments, TEXT(", ")));
Expand All @@ -1583,6 +1598,14 @@ void GenerateFunction_RPCSendCommand(FCodeWriter& SourceWriter, UClass* Class, c
TArray<TSharedPtr<FUnrealProperty>> RPCParameters = GetFlatRPCParameters(RPC);
for (auto Param : RPCParameters)
{
// TODO: UNR-152
if (Param->Property->IsA(UArrayProperty::StaticClass()))
{
FString ParamName = CPPFieldName(Param);
SourceWriter.Printf("// UNSUPPORTED TArray parameters (%s)", *ParamName);
continue;
}

FString SpatialValueSetter = TEXT("Request.set_") + SchemaFieldName(Param);

GenerateUnrealToSchemaConversion(
Expand Down Expand Up @@ -1674,9 +1697,20 @@ void GenerateFunction_RPCOnCommandRequest(FCodeWriter& SourceWriter, UClass* Cla
SourceWriter.Print("// Declare parameters.");
for (auto Param : RPC->Parameters)
{
FString PropertyValueCppType = Param.Value->Property->GetCPPType();
FString PropertyTemplateType;
FString PropertyValueCppType = Param.Value->Property->GetCPPType(&PropertyTemplateType);
FString PropertyValueName = Param.Value->Property->GetNameCPP();
SourceWriter.Printf("%s %s;", *PropertyValueCppType, *PropertyValueName);

// TODO: UNR-152 - this should be factored out to a utility function somewhere
if (Param.Value->Property->IsA(UArrayProperty::StaticClass()) && PropertyTemplateType.Len() > 0)
{
// Append the template type if it exists.
SourceWriter.Printf("%s%s %s;", *PropertyValueCppType, *PropertyTemplateType, *PropertyValueName);
}
else {
SourceWriter.Printf("%s %s;", *PropertyValueCppType, *PropertyValueName);
}

RPCParameters.Add(PropertyValueName);
}

Expand All @@ -1686,6 +1720,15 @@ void GenerateFunction_RPCOnCommandRequest(FCodeWriter& SourceWriter, UClass* Cla

for (auto Param : GetFlatRPCParameters(RPC))
{
// TODO: UNR-152
if (Param->Property->IsA(UArrayProperty::StaticClass()))
{
FString PropertyValueCppType = Param->Property->GetCPPType();
FString PropertyValueName = Param->Property->GetNameCPP();
SourceWriter.Printf("// UNSUPPORTED TArray parameters (%s %s)", *PropertyValueCppType, *PropertyValueName);
continue;
}

FString SpatialValue = FString::Printf(TEXT("%s.%s()"), TEXT("Op.Request"), *SchemaFieldName(Param));

GeneratePropertyToUnrealConversion(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Note that a majority of the items below are on our short term roadmap.

## Engine changes:

There is a small number of changes to UE4 source code we have to make. These changes are mostly limited in scope and they only consist of class access, polymorphism, and dll export related changes. We will attempt to consolidate and remove (or submit as PR to Epic) as many of these changes as possible. Our changes can be seen in our `UnrealEngine` repo, `UnrealEngine417_NUF` branch.
There is a small number of changes to UE4 source code we have to make. These changes are mostly limited in scope and they only consist of class access, polymorphism, and dll export related changes. We will attempt to consolidate and remove (or submit as PR to Epic) as many of these changes as possible. Our changes can be seen in our `UnrealEngine` repo, `UnrealEngine419_SpatialGDK` branch.

## How to use:

Expand All @@ -70,4 +70,4 @@ To register the module with your Unreal project, copy the `SpatialGDK` folder in
To register the editor plugin with your Unreal project, copy the `Plugins\SpatialGDK` into your project's `Plugins` folder.

### InteropCodeGenerator
TODO: revisit when we have a user-definied workflow
TODO: revisit when we have a user-definied workflow
2 changes: 1 addition & 1 deletion SpatialGDK/Private/SpatialNetConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void USpatialNetConnection::InitRemoteConnection(UNetDriver* InDriver, class FSo

}

bool USpatialNetConnection::ClientHasInitializedLevelFor(const UObject* TestObject) const
bool USpatialNetConnection::ClientHasInitializedLevelFor(const AActor* TestActor) const
{
check(Driver->IsServer());
return true;
Expand Down
4 changes: 2 additions & 2 deletions SpatialGDK/Private/SpatialNetDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool USpatialNetDriver::InitBase(bool bInitAsClient, FNetworkNotify* InNotify, c
FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &USpatialNetDriver::OnMapLoaded);

// Make absolutely sure that the actor channel that we are using is our Spatial actor channel
UChannel::ChannelClasses[CHTYPE_Actor] = USpatialActorChannel::StaticClass();
ChannelClasses[CHTYPE_Actor] = USpatialActorChannel::StaticClass();

// Create SpatialOS instance and setup callbacks.
SpatialOSInstance = NewObject<USpatialOS>(this);
Expand Down Expand Up @@ -862,7 +862,7 @@ USpatialNetConnection* USpatialNetDriver::AcceptNewPlayer(const FURL& InUrl, boo
if (bOk)
{
FString LevelName = GetWorld()->GetCurrentLevel()->GetOutermost()->GetName();
Connection->ClientWorldPackageName = GetWorld()->GetCurrentLevel()->GetOutermost()->GetFName();
Connection->SetClientWorldPackageName(GetWorld()->GetCurrentLevel()->GetOutermost()->GetFName());

FString GameName;
FString RedirectURL;
Expand Down
2 changes: 1 addition & 1 deletion SpatialGDK/Public/SpatialNetConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SPATIALGDK_API USpatialNetConnection : public UIpConnection
virtual void InitRemoteConnection(UNetDriver* InDriver, class FSocket* InSocket, const FURL& InURL, const class FInternetAddr& InRemoteAddr, EConnectionState InState, int32 InMaxPacket = 0, int32 InPacketOverhead = 0) override;
virtual void InitLocalConnection(UNetDriver* InDriver, class FSocket* InSocket, const FURL& InURL, EConnectionState InState, int32 InMaxPacket = 0, int32 InPacketOverhead = 0) override;
virtual void LowLevelSend(void* Data, int32 CountBytes, int32 CountBits) override;
virtual bool ClientHasInitializedLevelFor(const UObject* TestObject) const override;
virtual bool ClientHasInitializedLevelFor(const AActor* TestActor) const override;
virtual void Tick() override;

// These functions don't make a lot of sense in a SpatialOS implementation.
Expand Down
5 changes: 3 additions & 2 deletions SpatialGDK/SpatialGDK.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public SpatialGDK(ReadOnlyTargetRules Target) : base(Target)
"InputCore"
});

if (UEBuildConfiguration.bBuildEditor == true)
// Check if we're building in the editor.
if (Target.bBuildEditor)
{
// Required by USpatialGameInstance::StartPlayInEditorGameInstance.
PublicDependencyModuleNames.Add("UnrealEd");
}
}
}
}

0 comments on commit 40bbfbe

Please sign in to comment.