Compile Error trying to replicate static arrays and UStructs()

Dear Friends at Epic,

I’ve tried to replicate the following with no success, each version is trying to carry same data
over the network, which is 255 true or false values to know whether to hide certain landcapes for the client

Context: Please note I am doing this all within a class extending AStaticMeshActor, not sure if this is relevant

    //static array of uint8
    uint8 LandscapeHidden[255];
    
    //static array of int32
    int32 LandscapeHidden[255];

//struct version, code below

The Compile Error

I am getting a compile error along the lines of:

1>E:\RocketVictory\VictoryGame\Source\VictoryGame\Private\Editor\VictoryPower.cpp(46): error C2665: 'NEQ' : none of the 19 overloads could convert all the argument types
1>          c:\program files\rocket\engine\intermediate\builddata\include\engine\../../../../Source/Runtime/Engine/Classes/Vehicles/VehicleMovementComponent.h(128): could be 'bool NEQ(const FReplicatedVehicleState &,const FReplicatedVehicleState &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(58): or       'bool NEQ(uint8,uint8,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(59): or       'bool NEQ(int32,int32,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(60): or       'bool NEQ(uint64,uint64,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(61): or       'bool NEQ(uint32,uint32,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(62): or       'bool NEQ(float &,float &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(63): or       'bool NEQ(FVector &,FVector &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(66): or       'bool NEQ(FRotator &,FRotator &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(68): or       'bool NEQ(const UObject *,const UObject *,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(73): or       'bool NEQ(FName &,FName,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(74): or       'bool NEQ(FColor &,FColor &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(75): or       'bool NEQ(FLinearColor &,FLinearColor &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(76): or       'bool NEQ(FPlane &,FPlane &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(79): or       'bool NEQ(const FString &,const FString &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(80): or       'bool NEQ(const FRigidBodyState &,const FRigidBodyState &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(84): or       'bool NEQ(FVector2D &,FVector2D &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(85): or       'bool NEQ(FGuid &,FGuid &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(86): or       'bool NEQ(FRepMovement &,FRepMovement &,UPackageMap *,UActorChannel *)'
1>          C:\Program Files\Rocket\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(92): or       'bool NEQ(FNetworkGUID &,FNetworkGUID &,UPackageMap *,UActorChannel *)'
1>          while trying to match the argument list '(FLandscapeHiddenStruct, FLandscapeHiddenStruct, UPackageMap *, UActorChannel *)'

Here is my Struct version code

.h

    //LandscapeHiddenStruct
    USTRUCT()
    struct FLandscapeHiddenStruct
    {
    	GENERATED_USTRUCT_BODY()
    
    	//Vars
    	uint8 LandscapeHidden[255];	//only using 0 and 1
    	
    	//~~~~~~~~~~~~~~~~~~~
    	
    	//default properties
    	FLandscapeHiddenStruct()
    	{
    		LandscapeHidden[0] = 1;
    		
    		for (uint8 i = 1; i < 256; i++ )
    		{
    			LandscapeHidden[i] = 0;
    		}
    	}
    };

UCLASS(placeable)
class AVictoryPower : public AJoySMA
{
	GENERATED_UCLASS_BODY()
			

    //Landscapes
    public:
    	
    	//make static array
    	/*
    	Rep Retry
    	Only useful for struct properties. 
    	Retry replication of this property if it fails to be fully sent 
    	(e.g. object references not yet available to serialize over 
    	the network). For simple references this is the default, 
    	but for structs this is often undesirable due to the bandwidth cost, 
    	so it is disabled unless this flag is specified.
    	*/
    	UPROPERTY(Replicated, RepRetry)	
    	FLandscapeHiddenStruct LandscapeHidden;

here is my .cpp

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//							Replication List
int32* AVictoryPower::GetReplicationList(uint8* Recent, FPropertyRetirement* Retire, int32* Ptr, UPackageMap* Map, UActorChannel* Channel, FReplicationFlags RepFlags)
{
	Ptr = Super::GetReplicationList(Recent, Retire, Ptr, Map, Channel, RepFlags);

	//Landscapes
	DOREP(AVictoryPower, LandscapeHidden);
	
	return Ptr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Again please note this is a compile error so I’m not posting any other code about how I actually call/set LandscapeHidden values

Thanks!

Rama

Hello Rama,

I see two possible issues at first glance:

  1. Make sure to put the UPROPERTY() keyword above the “LandscapeHidden” member variable. Any properties in a struct that need to be replicated need to be marked with this keyword.
  2. You are using DOREP to mark your property for replication. When you use this macro, you also have to implement the NEQ macro. Take a look at UnrealNetwork.h for an example. You can put this NEQ function in the same file as the DOREP, as long as you implement it before the DOREP call.

Another alternative to #2 above, is to use DOREPSTRUCT, which doesn’t require a NEQ function.

Hope this helps!

-John

Woohooo!

Thanks so much for the answer John!

In my game I will be needing to replicate complex data structures extensively for my multiplayer in-game level editor (2+ people editing same world)!

So your UStruct() answer has saved me so much time!


Posted as separate answer for better code coloring

Thanks to John’s help:

For anyone interested, and for future forum searches, here’s two ways I now know how the array of 256 uint8’s can be replicated over the network! Neither method requires writing your own NEQ

in short

method 1 = use DOREPSTRUCT

method 2 = use DOREPARRAY

//Summary of easy replication of more complex data

.h

//LandscapeHiddenStruct
USTRUCT()
struct FLandscapeHiddenStruct
{
	GENERATED_USTRUCT_BODY()

	//Vars
	//Any properties in a struct that need to be replicated 
	//		need to be marked with UPROPERTY() -John
	UPROPERTY()
	uint8 LandscapeHidden[255];	//only using 0 and 1
	
	//~~~~~~~~~~~~~~~~~~~
	
	//default properties
	FLandscapeHiddenStruct()
	{
		LandscapeHidden[0] = 1;
		
		for (uint8 i = 1; i < 256; i++ )
		{
			LandscapeHidden[i] = 0;
		}
	}
};

UPROPERTY(Replicated, RepRetry)	
FLandscapeHiddenStruct LandscapeHidden2;
	
UPROPERTY(Replicated)
uint8 LandscapeHidden[255];

.cpp

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//							Replication List
int32* AVictoryPower::GetReplicationList(uint8* Recent, FPropertyRetirement* Retire, int32* Ptr, UPackageMap* Map, UActorChannel* Channel, FReplicationFlags RepFlags)
{
	Ptr = Super::GetReplicationList(Recent, Retire, Ptr, Map, Channel, RepFlags);

	//~~~ Static Arrays ~~~
	DOREPARRAY(AVictoryPower, LandscapeHidden);
	
	//~~~ UStructs ~~~
	DOREPSTRUCT(AVictoryPower, LandscapeHidden2);
	
	return Ptr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~