_Implementation and _Validate (4.9.2)

Are the _Implementation and _Validate definitions required in the header file when using server functions? I honestly can’t tell if there is a different using them or not using them, when it it comes to replicating.

The forums and other answers have a handful of answers for previous versions of the engine with some included information regarded GENERATED_BODY( ) and GENERATED_UCLASS_BODY( ) but I am still a bit confused on the whole thing.

Thanks.

I have found out that _Implementation and _Validate are required in the .h file, using using 4.9+ as GENERATED_UCLASS_BODY( ) is depreciated.

As an example, this would be a server function in a .h file:

UFUNCTION( Server, Reliable, WithValidation )
void ServerMyFunction( );
void ServerMyFunction_Implementation( );
bool ServerMyFunction_Validate( );

And this would be the .cpp:

void AMyClass::ServerMyFunction_Implementation( )
{
    // Code that would be run on the server after validation
}

bool ServerMyFunction_Validate( )
{
 return true;
}

And when using this server function, call:

ServerMyFunction( );

or,

AMyClassReference->ServerMyFunction( );
1 Like

I ran into the same issues compiling when trying to add:

UFUNCTION(Server, Reliable, WithValidation)

Vawx’s solution compiled for my project, with some minor changes:

.h file:

UFUNCTION(Server, Reliable, WithValidation )
void ServerMyFunction(int arg1, int arg2);

.cpp file:

void AMyClass::ServerMyFunction_Implementation(int arg1, int arg2)
{
    // Code that would be run on the server after validation
}

bool  AMyClass::ServerMyFunction_Validate(int arg1, int arg2)
{
 return true;
}

What’s the purpose of the validate function? I get that the implementation is what the server runs, but does it only run if the validation function returns true? Every example I’ve found so far are always just returning true;