PDA

View Full Version : Variable replication



Mr Evil
12-12-2007, 12:24 PM
So I have been looking at the UScript changes for UT3, and I like the fact that replicated functions can be declared as reliable/unreliable instead of in the replication statement, but what about variables? Their reliability can't be declared, so are they all automatically reliable now?

The UDN's UnrealScriptReference section on replication (http://udn.epicgames.com/Three/UnrealScriptReference.html#Replication) contains exactly zero information (except for yet another red link).

Tonester
12-12-2007, 12:32 PM
I'm assuming you aren't talking about local vars inside the reliable/unreliable functions so....

Variables still need to use the same replication method as previously. The only thing that has changed (to my knowlege) is the addition of new keywords for making entire functions reliable or not.

This is from the "changes in UE3" at the top of the UDN:

Replication - replication statements have changed in UE3:
The replication block is only used for variables now
Function replication is now defined by means of function specifiers ( Server, Client, Reliable )

Mr Evil
12-12-2007, 12:48 PM
If I try the same way as UT2004, like this:

replication
{
reliable if(Role==ROLE_Authority)
Foo;
}
Then the compiler gives this warning:

Warning, Reliabe/Unreliable keywords are no longer used in 'replication {}'
But you can't do this either:

reliable var Foo;
So how is reliability for variables determined?

Pfhoenix
12-12-2007, 12:49 PM
It's worth noting that prior to UE3, variables were all reliable, period. Even if you set a variable in an unreliable statement, they were still reliable. Reliability applied only to functions.

All that's changed is now you can declare variables repnotify (so that you know as soon as they're replicated to clients via the ReplicatedEvent call). No more need to put functions in the replication statement, as their replication was different from variables anyways. Beyond that, replication hasn't changed, and in fact, certain bugs from before remain still.

Pfhoenix
12-12-2007, 12:51 PM
Mr Evil : look in Actor.uc . You'll see that you simply declare :



if (Role == ROLE_Authority)
VarToRep;

Bob_Gneu
12-12-2007, 08:22 PM
That formatting has not helped anyone as of yet. The only mutators are using workarounds and hacks to be able to pull off the equivalence to replication, but they aren't replicating the data from what i have seen (of the twelve or so i have gone through).

Please consult our conversation herein for further information
http://utforums.epicgames.com/showthread.php?t=585333

Mr Evil
12-12-2007, 09:08 PM
It's worth noting that prior to UE3, variables were all reliable, period...
I never knew that. Lots of replication statements specified unreliable for variables in Epic's UT2004 code, so I assumed it did something. If all replicated variables are reliable then there's no problem.



That formatting has not helped anyone as of yet. The only mutators are using workarounds and hacks to be able to pull off the equivalence to replication, but they aren't replicating the data from what i have seen (of the twelve or so i have gone through)...
That's a different problem. Mutators only exist on the server and so they can't do replication at all.

Bonehed316
12-12-2007, 09:56 PM
Bingo.

All variables are basically reliable, though there are some quirks, I've noticed. bHidden, for example, doesn't like to replicate unless I force the Actor to require a net update. Might just be a net saturated instance, though. bNetDirty does change when SetHidden gets called, so..*shrug*

Keep in mind the usual, though. Replicated functions get sent immediately, where as replicated variables are sent at the end of tick.

Another really cool feature is that you now have ReplicatedEvent which gets called with the name of each variable that is received, after it is received, when you specify the property as repnotify. Very handy.