HeroEngine Forums

HeroEngine Support => General Discussion => Topic started by: GlorianLanTarini on Jun 23, 16, 03:19:21 AM

Title: [resolved] Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 23, 16, 03:19:21 AM
Hello.

For replicate information about some game objects to clients I use this method.

Code: [Select]
method ReplecateObject(node as NodeRef, client as ID)
  if node is kindof Bast_DestructibleObject
   
  else
    return
  .
  replicationGroup as NodeRef of Class _ReplicationGroup = me._replicationGroupRef
  if replicationGroup = None
    // Create replication group
    replicationGroup = CreateNodeFromClass( "_replicationGroup" )
    addAssociation( GetRootNode(), "base_hard_association", replicationGroup )
    replicationGroup._replicationPrimaryNode = node
    replicationGroup._AddClientDestination(client, None)
    me._replicationGroupRef = replicationGroup
  else
    replicationGroup._ReplicateNode(node)
    replicationGroup._AddClientDestination(client, None)
  .
  where node is kindof Bast_DestructibleObject
    node._replicationGroupRef = replicationGroup
  .
.

And I got this error:

Quote
ERROR:System:Replication error: Replication error 'GOM::addNodeFromPrototype (10606): error: with InternalException message 'addPrototypeToStorage() failed'' doing ReplicationGroupBase.cpp(1170):scCreateNode

But, when I checked nodes and group - all look fine. Only one thing wrong - there is no callback when node added or field updated. Fields param is fine - I think it's becouse of error.

Any ideas?
Title: Re: Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 23, 16, 02:43:33 PM
Hello,

_addClientDestination() requires the client to add, and the "entity" to be replicated.

The current code you posted above uses "None" instead of "node".

so its attempting to replicate "nothing" basically, which is likely giving you that error.

Try changing it to the following:


Code: [Select]
method ReplecateObject(node as NodeRef, client as ID)
  if node is kindof Bast_DestructibleObject
   
  else
    return
  .
  replicationGroup as NodeRef of Class _ReplicationGroup = me._replicationGroupRef
  if replicationGroup = None
    // Create replication group
    replicationGroup = CreateNodeFromClass( "_replicationGroup" )
    addAssociation( GetRootNode(), "base_hard_association", replicationGroup )
    replicationGroup._replicationPrimaryNode = node
    replicationGroup._AddClientDestination(client, node)
    me._replicationGroupRef = replicationGroup
  else
    replicationGroup._ReplicateNode(node)
    replicationGroup._AddClientDestination(client, node)
  .
  where node is kindof Bast_DestructibleObject
    node._replicationGroupRef = replicationGroup
  .
.



and see if that works for you.

the _AddClientDestination() method is usually handled in the _SO_Entered() method,
after the object in question checks to see if the client is in its client destination list,
and then the client is removed from the list during the _SO_Departed or _SO_Disappeared methods.
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 23, 16, 07:17:18 PM
I've tried it. Not working. As I had expected. Because the second parameter in the function _addClientDestination() - a reference to spatial entity. And I'm not using a spatial system for this replication group. So the attempt only create a new bug. And not removed existing one.
Apparently, it's something else. But thanks anyway for the idea.
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 24, 16, 06:31:36 AM
Some addition details.

Today I found - replication for this group don't work at all. I thought it work just because of value of the client fields, but equality to server value was just coincidence. So it don't work, but if I check nodes by CLI, I can see rep group and all my nodes in it's list.
Title: Re: Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 24, 16, 09:41:43 AM
Quote
And I'm not using a spatial system for this replication group


Ahh i thought you were dealing with default HE replication, it will not work without a spatial entity, period.
HE replication relies on the SaS and the Enter/Departed etc functions to control replication.

These are the only functions/methods that produce replication, which only occurs when and if a client is within the spatial range of that entity/object.  Every tree, rock, model etc is an entity and is replicated via the sas, by default.


If you're not using this system, then I'm sorry, i would have to be well aquainted with your custom replication system to give any further advice. 

The default HE system relies on the SaS system to replicate to both client and servers.
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 24, 16, 10:47:13 AM
I use default HE replication. It can use distance prioritization, but it's not necessary. For exemples - read this one: http://hewiki.heroengine.com/wiki/Replication_Script_Interface
And I call this problem strange because I have very same script which replicate another kind of nodes, and it work totaly fine.
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 24, 16, 11:09:44 AM
Hmm... I think - I know what it can be. Should try it tomorrow.
Title: Re: Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 24, 16, 01:21:12 PM
If you want to replicate to a single client in such a fashion, what you're doing might work depending on how its setup, but ive not seen any examples of it working in script(very old example on wiki).  Sas has been the foundation for replication itself.  there are other means of sending the data to a single client.   Plus using the Sas, its far easier to monitor/control what client gets what info and when, especially since that system is fully built already.

There are only a few things that generally cause replication errors like this, here are some:

client is not in the area which is trying to replicate the object to the client(possiblity)
fields on the server/client class do not match (less likely according to your error)

A strong reason for sas useage is that if your client is not within range of an object (visible or not) it usually does not recognize the object ID as valid and can cause problems when attempting to replicate.  If the node does not yet exist on the client (visible does not mean it exists in many circumstances) replication will fail, unless SendNodeToClientWithClass() has been called on the server (or similar marshall functions).

I'm sure you have your reasons, due to your design, for doing it this way.  About all that I can offer are the above reasons why replication might fail.

Good Luck
Title: Re: Strange replication problem. Did I miss something?
Post by: Jrome90 on Jun 24, 16, 04:22:48 PM

Quote
And I'm not using a spatial system for this replication group

Ahh i thought you were dealing with default HE replication, it will not work without a spatial entity, period.
HE replication relies on the SaS and the Enter/Departed etc functions to control replication.

It's actually pretty simple.

When I was learning replication quite some time ago I made a blackjack game that uses replication with no SAS.
Here is the code:
https://docs.google.com/document/d/1rLybwDbAR1798F3GRkPKafBpwyNTqlMvwstP3lZy9Vw/edit?usp=sharing
The replicated fields are at the bottom.

CreateNewGame() is only called when a game was created.
AddPlayer() is called when a player joins the game (After it was created)


GlorianLanTarini, When I don't get any callbacks when a field changes, or a node is replicated it's because I forgot to set the ClientDestination field of the server side.

Are the nodes being replicated to the client at all? You can check using the "/qn" console command. You probably already know this though.

Title: Re: Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 24, 16, 09:13:05 PM
Quote
A strong reason for sas useage is that if your client is not within range of an object (visible or not) it usually does not recognize the object ID as valid and can cause problems when attempting to replicate.  If the node does not yet exist on the client (visible does not mean it exists in many circumstances) replication will fail, unless SendNodeToClientWithClass() has been called on the server (or similar marshall functions).

I'm sure you have your reasons, due to your design, for doing it this way.  About all that I can offer are the above reasons why replication might fail.


emphasis on the last two sentences :)

If theres no way you could be in another area server than the one trying to replicate, then it might work.  however there have been alot of changes, and I still find no working version of that example.
So, can't offer any help to resolve the error other than the normal causes of replication issues.

SaS still plays a part in this , as it is what created the node on the client to begin with (if its a server object).
At any rate, if the node exists on the client, then there should be no error unless the classes dont match (or there have been changes and replication needs to be restarted for the object in the GoM).
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 27, 16, 07:02:53 AM
So, after two days of intense testing, I found out not much.
Nodes are not replicated to the client. Although the group is created. The callback is only to the function _OnReplicationGroupAdded(). Then there is the specified error, as many times as many nodes trying to replicate. That is, an error occurs when adding a node.
I checked the field properties a dozen times - it's fine.
I thought it might be related to a specific process, which are affected nodes before replication. But nodes exclusion from the process does not affect the error in any way.
I tried really a lot of options - nothing helps. The only thing I have not tried is to create a separate group for each node. But I find it too excessive.
Title: Re: Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 27, 16, 10:20:11 AM
does your replicated class contain any "noderef" fields by chance? or List of noderef?

Just curious as that can be an oversight i know sometimes.
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 28, 16, 01:28:52 AM
does your replicated class contain any "noderef" fields by chance? or List of noderef?

No.

But I read all the posts again. And noticed this:

There are only a few things that generally cause replication errors like this, here are some:

client is not in the area which is trying to replicate the object to the client(possiblity)

I call this replication process before all other game-specific replications. And maybe I'm doing it too early?

How do you think, what place in the scripts (on client or server) most appropriate to call replication?
When we can be sure that the character is already in the area?
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 28, 16, 05:26:08 AM
Well, I replaced call to script which execute when character in area with no doubt. Nothing changed. Same error.

After all - I think, maybe it is a engine bug? It's happening only with one group which I setup after last update. And error text say about script file with .cpp extension. Someone else setup new replication after last update?
Title: Re: Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 28, 16, 08:03:23 PM
while its always possible something happend last update, i don't see any changes for replication systems from previous code.   Also using the same method to replicate as above, im unable to produce the error.  so its hard to say whats wrong.

Couple more things to check (if you havent already):

Do any classes on the node share the same field?


Quote
Well, I replaced call to script which execute when character in area with no doubt. Nothing changed. Same error.

Okay, so that one is ruled out.


This node isn't an "instance" type by chance is it?
I see that the class refers to a destructible object.  As instances are replicated by default, attempting to replicate them again also causes errors.  Just curious.

Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 28, 16, 10:09:08 PM
Quote
This node isn't an "instance" type by chance is it?
I see that the class refers to a destructible object.  As instances are replicated by default, attempting to replicate them again also causes errors.  Just curious.

I mentioned the process:
Quote
I thought it might be related to a specific process, which are affected nodes before replication. But nodes exclusion from the process does not affect the error in any way.
This process was associated with the instance creation on the client. And I guessed that this might be the cause of the error and excluded these nodes from the process. But, the error still here. Although instances now just don't exist.

Maybe I should describe (give code) the whole chain of events? From the initial call to error.
Title: Re: Strange replication problem. Did I miss something?
Post by: GlorianLanTarini on Jun 28, 16, 11:51:27 PM
Sometimes you need to be extremely careful. And do not think that everything happens as you want.

I had a very thorough analysis and finally found the cause of the error.

The reason of main problem was that I used the lookup list for choosing nodes to add to the group. And just after checking through the CLI absolutely all involved nodes and lists, I found out that indexers is added to the group, not the node it points to.

And with callbacks turned out all stupid. :-[
For some unknown even to me reason, I decided  to use HE_ version of the callback methods. Despite the fact that the nodes do not have parent class with a simple version. So, it's just never called.
Title: Re: [resolved] Strange replication problem. Did I miss something?
Post by: ToY-Krun on Jun 29, 16, 12:20:13 PM
most problems turn out to be something that simple heh.  Don't feel bad.