logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic What variables are guaranteed to be replicated at the moment of calling PostNetBeginPlay? (Read 458 times)
Masterkent
Developer Team
Offline



Posts: 1330
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
What variables are guaranteed to be replicated at the moment of calling PostNetBeginPlay?
May 9th, 2019 at 7:47am
Print Post  
As far as I could see, PostNetBeginPlay may be invoked after replication of some subset of replicated variables, while the rest of variables may be replicated later. Are there variables that are guaranteed to be replicated at the moment of calling PostNetBeginPlay? In particular, if the replicated actor is spawned with a specified owner and the ownership is not changed later server-side, can we expect that variables Owner and bNetOwner should have the relevant values in PostNetBeginPlay?
  
Back to top
 
IP Logged
 
.:..:
Board Moderator
Developer Team
*****
Offline



Posts: 1466
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: What variables are guaranteed to be replicated at the moment of calling PostNetBeginPlay?
Reply #1 - Jun 9th, 2019 at 5:42am
Print Post  
By definition engine tries to replicate ALL actor variables the same frame it spawns the actor clientside, PostNetBeginPlay is just called right after PostBeginPlay after client has read all the networked variables.

Only variables that may be delayed are actor reference variables if the refereed actor is not yet replicated to the client (such as Owner).
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1330
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: What variables are guaranteed to be replicated at the moment of calling PostNetBeginPlay?
Reply #2 - Jun 9th, 2019 at 2:26pm
Print Post  
.:..: wrote on Jun 9th, 2019 at 5:42am:
Only variables that may be delayed are actor reference variables if the refereed actor is not yet replicated to the client (such as Owner).

As far as I could see, replication of variables may be delayed if the total size of replicated data would exceed some limit. Consider the following example:

Code
Select All
class RepTest expands Info;

var string S1, S2, S3, S4, S5;

replication
{
	reliable if (LogReplicationCondition("S1"))
		S1;
	reliable if (LogReplicationCondition("S2"))
		S2;
	reliable if (LogReplicationCondition("S3"))
		S3;
	reliable if (LogReplicationCondition("S4"))
		S4;
	reliable if (LogReplicationCondition("S5"))
		S5;
}

function bool LogReplicationCondition(string VarDesc)
{
	Log("Evaluated replication condition - Var:" @ VarDesc @ " NetMode:" @ Level.GetPropertyText("NetMode") @ " Timestamp:" @ Level.TimeSeconds);
	return true;
}

event BeginPlay()
{
	local int i;
	local string S;

	const StrLen = 440;

	for (i = 1; i < StrLen; ++i)
		S $= "x";
	S1 = Left(S, 219) $ "1";
	S2 = Left(S, 219) $ "2";
	S3 = S $ "3";
	S4 = S $ "4";
	S5 = S $ "5";
}

simulated event PostBeginPlay()
{
	if (Level.NetMode != NM_Client)
		return;
	Log("Client PostBeginPlay Timestamp:" @ Level.TimeSeconds);
	LogVarValues();
}

simulated event PostNetBeginPlay()
{
	Log("Client PostNetBeginPlay Timestamp:" @ Level.TimeSeconds);
	LogVarValues();
}

simulated event PostNetReceive()
{
	Log("Client PostNetReceive Timestamp:" @ Level.TimeSeconds);
	LogVarValues();
}

simulated function LogVarValues()
{
	Log("    S1:" @ Len(S1) @ Right(S1, 4));
	Log("    S2:" @ Len(S2) @ Right(S2, 4));
	Log("    S3:" @ Len(S3) @ Right(S3, 4));
	Log("    S4:" @ Len(S4) @ Right(S4, 4));
	Log("    S5:" @ Len(S5) @ Right(S5, 4));
}

defaultproperties
{
	bNetNotify=True
	RemoteRole=ROLE_SimulatedProxy
} 


with the server & client logs:

Code
Select All
ScriptLog: Evaluated replication condition - Var: S1  NetMode: NM_DedicatedServer  Timestamp: 8.177000
ScriptLog: Evaluated replication condition - Var: S2  NetMode: NM_DedicatedServer  Timestamp: 8.177000
ScriptLog: Evaluated replication condition - Var: S3  NetMode: NM_DedicatedServer  Timestamp: 8.177000
ScriptLog: Evaluated replication condition - Var: S4  NetMode: NM_DedicatedServer  Timestamp: 8.177000
ScriptLog: Evaluated replication condition - Var: S5  NetMode: NM_DedicatedServer  Timestamp: 8.177000
ScriptLog: Evaluated replication condition - Var: S3  NetMode: NM_DedicatedServer  Timestamp: 8.194000
ScriptLog: Evaluated replication condition - Var: S4  NetMode: NM_DedicatedServer  Timestamp: 8.194000
ScriptLog: Evaluated replication condition - Var: S5  NetMode: NM_DedicatedServer  Timestamp: 8.194000
ScriptLog: Evaluated replication condition - Var: S4  NetMode: NM_DedicatedServer  Timestamp: 8.211000
ScriptLog: Evaluated replication condition - Var: S5  NetMode: NM_DedicatedServer  Timestamp: 8.211000
ScriptLog: Evaluated replication condition - Var: S5  NetMode: NM_DedicatedServer  Timestamp: 8.228001 


Code
Select All
ScriptLog: Client PostBeginPlay Timestamp: 4.372000
ScriptLog:     S1: 0
ScriptLog:     S2: 0
ScriptLog:     S3: 0
ScriptLog:     S4: 0
ScriptLog:     S5: 0
ScriptLog: Client PostNetReceive Timestamp: 4.372000
ScriptLog:     S1: 220 xxx1
ScriptLog:     S2: 220 xxx2
ScriptLog:     S3: 0
ScriptLog:     S4: 0
ScriptLog:     S5: 0
ScriptLog: Client PostNetBeginPlay Timestamp: 4.372000
ScriptLog:     S1: 220 xxx1
ScriptLog:     S2: 220 xxx2
ScriptLog:     S3: 0
ScriptLog:     S4: 0
ScriptLog:     S5: 0
ScriptLog: Client PostNetReceive Timestamp: 4.389000
ScriptLog:     S1: 220 xxx1
ScriptLog:     S2: 220 xxx2
ScriptLog:     S3: 440 xxx3
ScriptLog:     S4: 0
ScriptLog:     S5: 0
ScriptLog: Client PostNetReceive Timestamp: 4.406000
ScriptLog:     S1: 220 xxx1
ScriptLog:     S2: 220 xxx2
ScriptLog:     S3: 440 xxx3
ScriptLog:     S4: 440 xxx4
ScriptLog:     S5: 0
ScriptLog: Client PostNetReceive Timestamp: 4.423000
ScriptLog:     S1: 220 xxx1
ScriptLog:     S2: 220 xxx2
ScriptLog:     S3: 440 xxx3
ScriptLog:     S4: 440 xxx4
ScriptLog:     S5: 440 xxx5 


Although we assign the values of S1 - S5 in BeginPlay which is executed in a single tick, these 5 strings contain too much data in total to be replicated at once, so the server replicates these vars part by part - in 4 ticks (S1 & S2, then S3, then S4, and then S5). The client calls PostNetBeginPlay right after handling the initial portion of replicated data that includes the values of S1 and S2, but not the values of S3, S4, and S5, which are received later on in subsequent client-side ticks.

Therefore, in general, we should be careful when using replicated vars in PostNetBeginPlay, because some vars may not have expected values at the moment of calling PostNetBeginPlay yet. This leads me to a question about what subset of variables is actually guaranteed to be replicated at that moment.

For example, if I have something like this:

Code
Select All
var PlayerPawn PlayerOwner;

simulated event PostNetBeginPlay()
{
	if (bNetOwner)
		PlayerOwner = PlayerPawn(Owner);
} 


where Owner is known to be assigned only once by using the corresponding parameter of Spawn (called server-side), can I be sure that if the client-side value of Owner matches the local player, then replication of bNetOwner and Owner won't be delayed (considering possible subclasses which can be written by other people who may add an unpredictable number of replicated vars there)?
  
Back to top
 
IP Logged
 
.:..:
Board Moderator
Developer Team
*****
Offline



Posts: 1466
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: What variables are guaranteed to be replicated at the moment of calling PostNetBeginPlay?
Reply #3 - Jun 22nd, 2019 at 8:40am
Print Post  
That's most unfortunate, it seams as the replicate actor function stops sending more variables once that one packet has overflowed. So there will be no consistency on that since it could be sending a lot other actors in same time.

Plus there is no signature packet for once initial variables has been sent for an actor. Adding that would break network compatibility with older versions.
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo