[4.7p2] server rpc declaration?

Hey all,

How am i supposed to deal with server rpc declaration in 4.7 ?

I have a ton of warnings like that one:

warning C4996: Function YagActor::ServerSetBodyTexturePath needs native implementation by virtual void ServerSetBodyTexturePath_Implementation(const FString& NewBodyTexturePath) due to its properties.

Maybe it is obvious and self explanatory but i am not a big guy in c++ and couldn’t find a way to get rid of those.

Could anyone give me an example of how server rpc should be declared since 4.7 ?

Thanks !

Seeing your code would be nice, otherwise it’s hard to tell what you may did wrong. Did your declaration work in 4.6? If not, have you checked this wiki article?

Hi,

Here is the code.

UFUNCTION(Server, WithValidation, Reliable)
	void ServerSetBodyTexturePath(const FString& NewBodyTexturePath);

--------------------------------------------------------------------------------------------------


bool AYagActor::ServerSetBodyTexturePath_Validate(const FString& NewBodyTexturePath)
{
	return true;
}

void AYagActor::ServerSetBodyTexturePath_Implementation(const FString& NewBodyTexturePath)
{
	bla bla
}

It has been working forever, 4.6 included, so i thought it was a 4.7 change.

Cheers

Hmpf, i’,m not that good in C++, but i can’t find examples with “virtual” replicated functions. Would you mind trying to declare it without the “virtual”? :X

sorry, that was a typo, one of my tries to get rid of the warnings :smiley:
I have corrected the posted code^^

I don’t have 4.7 here at the moment. How about you add virtual back to it and also to the

virtual void AYagActor::ServerSetBodyTexturePath_Implementation(const FString& NewBodyTexturePath)
 {
     bla bla
 }

But i’m just guessing here :X Would be better to maybe ask in the 4.7 Preview forum thread.

Already tried that, unfortunately i get a compilation error.

Yeah, i’ll wait a bit and if nobody has a better idea here, i’ll try the forum.

Anyway, thanks a lot for your time and suggestions :slight_smile:

Hi uced,

Sorry for not responding to your post sooner. Are you seeing the warnings that you mentioned in Visual Studio when you try to build your project? I just tried adding the code you provided above and was able to build a project without any problems in 4.7 Preview 3. Have you run into the same warnings in Preview 3?

Hi ,

Thanks for your answer.

Yes, i’m using visual studio + 4.7 preview 3 (launcher version) and still have the warnings so far.

They didn’t exist before, they appeared suddenly in 4.7 (p1, p2, p3) with no change in the code. First time i compiled in 4.7 they appeared, i thought i was the normal “get rid of the warnings in new version” routine, except i couldn’t get rid of them^^

There has been some discussion about it in the forum:

At least one other person is experiencing this problem:

I have one warning per server rpc. Strangely enough, sometimes the same list or warnings repeats itself many times, resulting in a huge number of warning lines, sometimes i get only one copy of the list, that seems random, i couldn’t identify a trigger.

Long story short: no clue, 2 people has the pb as far as i know, but most don’t apparently.

Chances are strong that i am doing something wrong, but i am short of ideas now.

Cheers

I am still discovering c++ and VS (in french !), so just to be clear for me: if they are the commands associated with F7 (build) and ctrl-alt-F7 (rebuild) then yes, i used both of them extensively many many time (sometimes with some “cleaning the solution”) and the warnings never disappear.

I think I was able to see the warning messages that you described. However, I only get them when I do a Rebuild in Visual Studio. If I do a standard Build, the messages don’t appear. Do you see them even when doing a regular Build?

Hi ,

I made some more careful tests and read about build/rebuild, it now makes more sense.

When i build, i get the warnings from the headers parsed in modified files only. That’s why the number seemed random, it actually is depending on the files i modified before building.

When i rebuild, i get the full list of warnings for each headers in all the project.

If the same header appears many times in the project, its list of warnings will be repeated as much.

So in short, it gives a warning for each rpc it encounters in the headers parsed during builing/rebuilding.

So if you modify only a file that does not include any “declaring-rpcs-header”, you will get no warnings (i did this on a dummy file).

If you modify a file containing somehow (through included headers) server rpcs declaration, i bet you will get the warning even on a simple build.

Hope it helps.

Cheers

Warnings are still there in preview 4.

I have started a brand new code (4.7p4 / c++ / basic code), just added an AActor derived class with this code

UFUNCTION(server, withvalidation, reliable)
	void ServerMove(FVector Velocity, bool bSweep);

-------------------------------------------------------------------------------------

bool ASpider::ServerMove_Validate(FVector Velocity, bool bSweep){ return true; }
void ASpider::ServerMove_Implementation(FVector Velocity, bool bSweep)
{
	AddActorWorldOffset(Velocity, bSweep);
}

Et voila:

1>C:\Users\\Documents\Unreal Projects\SpiderTest\Source\SpiderTest\Spider/Spider.h(14)( : warning C4996: Function Spider::ServerMove needs native implementation by virtual void ServerMove_Implementation(FVector Velocity, bool bSweep) due to its properties. Currently ServerMove_Implementation declaration is autogenerated by UHT. Since next release you'll have to provide declaration on your own. Please update your code before upgrading to the next release, otherwise your project will no longer compile.

All this was made in 4.7 preview 4.

Hi,

This code is working:

UFUNCTION(server, withvalidation, reliable)
	void ServerMove(FVector Velocity, bool bSweep); 
virtual bool ServerMove_Validate(FVector Velocity, bool bSweep);
virtual void ServerMove_Implementation(FVector Velocity, bool bSweep);

Could anyone from epic staff please confirm that this is correct and should be used for rpc declarations from now on ?

Thanks

All right, this is official now, the whole story is here:

uced, thank you for working through this issue. I missed out on the 4.7 previews, but ran into these warnings in the release versions. Your forum post and topic here helped resolve the problem quickly (I too was getting fail to compiles for a while with the _Validate not included.

Hi,

you get this Warning because auf the changes they made in Version 4.7. Klick here for an answer: Link

In 4.7+ your header has to look linke this:

UFUNCTION(...)
virtual void ServerSetBodyTexturePath(const FString& NewBodyTexturePath)
virtual void ServerSetBodyTexturePath_Implementation(const FString& NewBodyTexturePath)

Hey Ra_ar, thanks for the feedback, always glad to be helpful :slight_smile: