"Missing variable name in replication definition"... ...No?

Discussions about Coding and Scripting
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

Wormbo wrote:Replication is a tricky thing and understanding network roles of actors is part of mastering replication. Try reading some replication articles again carefully. It's all mentioned in most of them, but you need to get used to the specific wording before you can fully understand the consequences of each detail the various articles.

Generally, a network client swaps Role and RemoteRole of any actors it received. Role is the role an actor has locally, RemoteRole is the role the actor has on the other side of the virtual replication channel. A server always has ROLE_Authority where it was originally created and some role less than ROLE_Authority, i.e. ROLE_AutonomousProxy, ROLE_SimulatedProxy, ROLE_DumbProxy or even ROLE_None for non-replicated mapper-placed static/no-delete actors.
No not confuse roles with network modes. An Unreal Engine instance can run in any of four modes: NM_Standalone (no networking), NM_DedicatedServer (just the server side, no local "viewport", i.e. window to view the action), NM_ListenServer (a network server with a local viewport) and NM_Client (only a network client). The first three will usually only have Role==ROLE_Authority actors, while the last one will usually have mostly Role<ROLE_Authority actors, except for those spawned locally.
Replication conditions tell about the "source side" of the replication channel. A condition has to be true on the server for variables or function calls to be replicated to the client, while it has to be true on the (owning) client for function calls to be replicated to the server.

This all has been documented in various (but usually good) detail in the many replication articles and tutorials out there, but it really takes time to understand. Allow yourself that time to let the concepts settle in your mind.
The problem is that I think at these ROLEs ONLY as constants. I see there's a variable "role" that, thanks to one of these ROLEs, gives a symbolic role to the actor.
To express a symbolic idea like this one, inside a code, you need to use them as constants/variables checking them or modifying them, but, usually, programmers put enough documentation next to these constants, cause they represent a symbolic idea. But what I see here is that there is not so much documentation, I read

Code: Select all

	ROLE_DumbProxy;	// Dumb proxy of this actor.
.

You know what? Nvm, I just saw them as names, but I didn't translate them in my mind .o. Now I understand what proxy means, it means like a clone, right? :D
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: "Missing variable name in replication definition"... ...

Post by sektor2111 »

PrinceOfFunky wrote:The problem is that I think at these ROLEs ONLY as constants
Wrong for you then, these are variable and can be modified. Take your time to lecture Uscript from BotPack. It will help you.
And now if your time is limited then I'll show you examples.
One of grenades used by me exploding with effects in client-only and the rest having RENDER:

Code: Select all

class MHGrenade expands Grenade;

simulated function Explosion(vector HitLocation)
{
	local MHSpriteBallExplosion s;

	BlowUp(HitLocation);
	if ( Level.NetMode != NM_DedicatedServer )
	{
		spawn(class'Botpack.BlastMark',,,,rot(16384,0,0));
		s = spawn(class'MHSpriteBallExplosion',,,HitLocation);
		s.RemoteRole = ROLE_None; //It's not any constant, they cannot be assigned normally LOL
	}
	Destroy();
}
PlayerShadow from Bot spawning only if we are not in dedicated servers

Code: Select all

simulated function PostBeginPlay()
{
	if ( class'GameInfo'.Default.bVeryLowGore )
		bGreenBlood = true;
	InitRating();
	Super.PostBeginPlay();
	if ( Level.NetMode != NM_DedicatedServer )
		Shadow = Spawn(class'PlayerShadow',self);
}
FlakSlug projectile

Code: Select all

simulated function PostBeginPlay()
{
	if ( !Region.Zone.bWaterZone && (Level.NetMode != NM_DedicatedServer) )
		Trail = Spawn(class'ChunkTrail',self);
......
How I fixed for a retarded projectile inside mutator

Code: Select all

function DoProjTweak() //Lousy class left to mock - Good night! Cute simple fast fix.
{
	class 'BigBioGel'.default.RemoteRole=ROLE_SimulatedProxy;
}
If you can see or not these examples of Net Stuff are addressing client, there is main visual action which are called by authority in SIMULATED functions not what you did. It's not easy to check default examples + trying small stuff first rather than doing a blind coding?
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: "Missing variable name in replication definition"... ...

Post by Wormbo »

PrinceOfFunky wrote:...
You need to be very precise when reading code, because a compiler doesn't leave the slightest room for interpretation.

Look at the declaration of the ENetRole enum and the Role and RemoteRole variables again:

Code: Select all

// Net variables.
enum ENetRole
{
	ROLE_None,              // No role at all.
	ROLE_DumbProxy,			// Dumb proxy of this actor.
	ROLE_SimulatedProxy,	// Locally simulated proxy of this actor.
	ROLE_AutonomousProxy,	// Locally autonomous proxy of this actor.
	ROLE_Authority,			// Authoritative control over the actor.
};
var ENetRole Role;
var(Networking) ENetRole RemoteRole;
It couldn't be any more clear: The type ENetRole can take on any one of the five specified values, which happen to be ordered exactly as listed - ROLE_None is the smallest, ROLE_Authority is the largest. (This is important because you can use not only equality operators, but also the other comparison operators.) Both Role and RemoteRole are variables of type ENetRole. You don't even really need to know the concept of a proxy (okay, it certainly helps), you only need to acknowledge the fact that the actor on the client and the one on the server are not necessarily the same. They are merely connected by a virtual channel that transports selected updates, everything else is "simulated" on the client. (I mean really everything, not just "simulated proxies". "Just standing there" may also be a simple form of simulation.)

The only thing you can't see in the Actor source code is the replication magic that swaps an actor's Role and RemoteRole values for replicated actors on the client side. That's why most replication-related articles and tutorials mention this specific fact, e.g. as follows:
[...] All of the remaining actors will have their Role and RemoteRole values exchanged, [...]
and
[...] The most important part here is that the actor gets its Role and RemoteRole values exchanged before any UnrealScript code is executed.
I know it's a lot of text, regardless whether you choose to read my article or anyone else's, but that's because replication is just that complex. The ruleset makes perfect sense once you understood it, but the road to that understanding may be uncomfortably long and unpleasant, depending on how carefully you walk it.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

sektor2111 wrote:
PrinceOfFunky wrote:The problem is that I think at these ROLEs ONLY as constants
Wrong for you then, these are variable and can be modified.
I know it's a lot of text, regardless whether you choose to read my article or anyone else's, but that's because replication is just that complex[/quote]
I did read it all some weeks ago, the problem is not the replication, but the ROLEs.

Some questions I still have about them are:
1. Is the ROLE initializated to ROLE_None, if a ROLE was not specified into the "default_properties" and, is it initialized inside the "default_properties"?
2. Why, if I created two variables(ReplicatedIntVar and NonReplicatedIntVar) and I put "ReplicatedIntVar" inside a "reliable if" body, the value of "NonReplicatedIntVar" was correct inside the server? It might not be correct inside the Server cause it's not sent to the server, and even if the code would be run by the server, the value might not be correct inside the client, but it is always correct :/
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: "Missing variable name in replication definition"... ...

Post by Wormbo »

Default property values of any kind are always inherited from the parent class. Class Actor defines:

Code: Select all

defaultproperties
{
     Role=ROLE_Authority
     RemoteRole=ROLE_DumbProxy
Read more code. ;)

[edit]
And IIRC you didn't actually provide any proof the client really sees the same value as the server on a replicate instance in the client side log file.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

Wormbo wrote:Default property values of any kind are always inherited from the parent class. Class Actor defines:

Code: Select all

defaultproperties
{
     Role=ROLE_Authority
     RemoteRole=ROLE_DumbProxy
Read more code. ;)

[edit]
And IIRC you didn't actually provide any proof the client really sees the same value as the server on a replicate instance in the client side log file.
Oh well, thanks, I actually never checked the Default Properties of the "Actor" class.
I didn't say it but, my bro joined my server some days ago, and he got correct values(as I put them to be shown with "BroadcastMessage").
But maybe the code to send messages to players use a replicated String variable, Idk .o.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: "Missing variable name in replication definition"... ...

Post by sektor2111 »

I cannot explain more if you insist to speak dumb things.
BROADCASTMESSAGE is a different thing - is a text message. You have to hook message if you want something from it which AGAIN i did not see in your codes. And because you don't want to understand my statements and Wormbo's, is pointless for to keep explaining how things works. You have quotting entire posts but I don't see you reading them neither trying to figure purpose.

Aside: get that messed WSRH and add it in "package". Put a log at Animations section, go figure logs... change that stupid DUMB_Proxy with Simulated and see... it's a simple replication thing shared originally by Gust, then "re-coded" by another "coder" using Copy-Paste...
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

sektor2111 wrote:I cannot explain more if you insist to speak dumb things.
BROADCASTMESSAGE is a different thing - is a text message. You have to hook message if you want something from it which AGAIN i did not see in your codes. And because you don't want to understand my statements and Wormbo's, is pointless for to keep explaining how things works. You have quotting entire posts but I don't see you reading them neither trying to figure purpose.

Aside: get that messed WSRH and add it in "package". Put a log at Animations section, go figure logs... change that stupid DUMB_Proxy with Simulated and see... it's a simple replication thing shared originally by Gust, then "re-coded" by another "coder" using Copy-Paste...
If you think it's pointless, why are you still posting?
(usually helps are for those who didn't understand something in a forum... ...usually .o.)
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: "Missing variable name in replication definition"... ...

Post by sektor2111 »

Okay, cya then...
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: "Missing variable name in replication definition"... ...

Post by Wormbo »

Since you mention BroadcastMessage: That is a broadcast from the serverside code to the clientside console. It can't even be used on a client, because you need a GameInfo for that, which only exists on the server. The broadcasted string is build locally where the call happens (i.e. serversidely) and then distributed to all clients. Stick with the log file if you really want to know what happens where.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

Wormbo wrote:Since you mention BroadcastMessage: That is a broadcast from the serverside code to the clientside console. It can't even be used on a client, because you need a GameInfo for that, which only exists on the server. The broadcasted string is build locally where the call happens (i.e. serversidely) and then distributed to all clients. Stick with the log file if you really want to know what happens where.
Well, thank you, if its string is "server-sidely", then, how did my brother read the same message as mine?
The messages contained these strings:

Code: Select all

Log("NonReplicatedIntVar  = "$VReplicator.NonReplicatedIntVar);
Log("ReplicatedIntVar = "$VReplicator.ReplicatedIntVar);
Where: ReplicatedIntVar is contained inside the "reliable" body, and NonReplicatedIntVar is not contained inside the "reliable" body.
My bro got the same message as mine with the same exact values for both of the variables, so I guess, this means, the codes I posted are both executed serversidely? :o
Cause from what I tough, my bro had no way to know the exact value of "NonReplicatedIntVar"...
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: "Missing variable name in replication definition"... ...

Post by Wormbo »

You don't have any clientside code whatsoever in your class, so it's really impossible you ever output actual clientside values anywhere.
You seem to expect something magic to happen. Unless you read about some "magic" behavior in a tutorial somewhere (like Role/RemoteRole swapping on clients, or e.g. the simulation context awareness of PlaySound), you must not expect anything to happen that is not explicitly mentioned in your code.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

Wormbo wrote:You don't have any clientside code whatsoever in your class, so it's really impossible you ever output actual clientside values anywhere.
You seem to expect something magic to happen. Unless you read about some "magic" behavior in a tutorial somewhere (like Role/RemoteRole swapping on clients, or e.g. the simulation context awareness of PlaySound), you must not expect anything to happen that is not explicitly mentioned in your code.
And this is exactly what I didn't understood properly, what's an example of ClientSide code? Client inputs maybe?
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: "Missing variable name in replication definition"... ...

Post by Wormbo »

Take GameReplicationInfo, for example. Its PostBeginPlay() is executed on the server and all clients - not due to magic, but due to GRI being RemoteRole=ROLE_SimulatedProxy and bAlwaysRelevant=True and PostBeginPlay being simulated.

Learn to think more strictly in replication terms. Your server and your client are two totally independent instances of the Unreal Engine. They both execute UnrealScript code, but not the same code at the same time. They exchange messages to tell each other about new Actors in the world, value updates for known replicated Actors and sometimes even about functions to execute and what values to pass to the respective parameters. (I'm not quite sure why I write that again here when I already explained it in my replication article...)
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: "Missing variable name in replication definition"... ...

Post by PrinceOfFunky »

Wormbo wrote:Take GameReplicationInfo, for example. Its PostBeginPlay() is executed on the server and all clients - not due to magic, but due to GRI being RemoteRole=ROLE_SimulatedProxy and bAlwaysRelevant=True and PostBeginPlay being simulated.

Learn to think more strictly in replication terms. Your server and your client are two totally independent instances of the Unreal Engine. They both execute UnrealScript code, but not the same code at the same time. They exchange messages to tell each other about new Actors in the world, value updates for known replicated Actors and sometimes even about functions to execute and what values to pass to the respective parameters. (I'm not quite sure why I write that again here when I already explained it in my replication article...)
I see there's a variable called "SecondCount" inside the simulated function "PostBeginPlay()" from the class "GameReplicationInfo":

Code: Select all

simulated function PostBeginPlay()
{
	if( Level.NetMode == NM_Client )
	{
		// clear variables so we don't display our own values if the server has them left blank 
		ServerName = "";
		AdminName = "";
		AdminEmail = "";
		MOTDLine1 = "";
		MOTDLine2 = "";
		MOTDLine3 = "";
		MOTDLine4 = "";
	}

	SecondCount = Level.TimeSeconds;
	SetTimer(0.2, true);
}
That variable is not inside the reliable block, so, will it be modified serveridely or, it will be modified on both the sides?
"Your stuff is known to be buggy and unfinished/not properly tested"
Post Reply