Author Topic: I'm in RFC id hell right now. (Parameters don't match.)  (Read 2331 times)

RFCsDriveMeNuts

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 12
    • View Profile
I'm in RFC id hell right now. (Parameters don't match.)
« on: February 23, 2014, 02:15:34 AM »
-What are the rules of RFC numbers? 
-I would assume they need to be unique per script, but what about across the project? 
-What about RCCs?  Do they share the same pool?  If so, why are RFCs bytes and RCCs ints?

My first remote function anything was an RCC:

   
  1.     public enum EMessageType : byte
  2.     {
  3.         //1 I think is for syncing rigid bodies.
  4.         createPlayer = 243, //me now trying random values
  5.         playerUpdate = 3
  6.     }
  7.  
  8.     internal void SpawnPlayer(Vector3 position, Quaternion rotation, string faction)
  9.     {
  10.         TNManager.CreateEx((int)EMessageType.createPlayer, false, player, position, rotation, faction);
  11.        
  12.     }
  13.    
  14.     [RCC((int)EMessageType.createPlayer)]
  15.     private void OnSpawnPlayer(GameObject prefab, Vector3 position, Quaternion rotation, string faction)
  16.     {
  17.         GameObject go = (GameObject)Instantiate(prefab, position, rotation);
  18.         CPhysicsPlayer player = go.GetComponent<CPhysicsPlayer>();
  19.         Debug.Log("this is working? " + player.name);
  20.     }

Which seemed to work fine for a while, until I added my first RFC in a different script:

To call it:

       
  1.         if (myTNObject.isMine)
  2.         {
  3.             myTNObject.SendQuickly((byte)CNetworkManager.EMessageType.playerUpdate, TNet.Target.OthersSaved, forwardInput, strafeInput, primaryInput, secondaryInput, useInput);
  4.         }

The function it is calling:

   
  1.     [RFC((byte)CNetworkManager.EMessageType.playerUpdate)]
  2.     private void Receive_Update(float forwardInput, float strafeInput, bool primaryInput, bool secondaryInput, bool useInput)
  3.     {
  4.         this.forwardInput = forwardInput;
  5.         this.strafeInput = strafeInput;
  6.         this.primaryInput = primaryInput;
  7.         this.secondaryInput = secondaryInput;
  8.         this.useInput = useInput;
  9.     }
  10.  
Now I have been swimming in "parameters don't match" Hell for an hour (it's like Windows 9X all over again with DLLs!).  I assumed the worst case scenario and made all IDs unique across all my scripts. 

I have deleted the server.dat I found, and I have yet to see another one.

I have restarted the stand-alone server multiple times.

Once I switched my SpawnPlayer to a random number, it resumed working without any parameter issues, except now none of my objects synchronize movement anymore.

What in the world is going on?!?!  All I am trying to do is spawn one player prefab per player and have them move, but this is like pulling teeth.

Thanks in advance.  I am sure it's something I'm doing wrong, but I feel like documentation is rather scant on the particulars.

EDIT: Well, I gave up on the RCCs and my objects' movement is synchronizing again.  I have been wandering the forums and it was hinted that the RCCid is actually the ID given to the TNObject upon instantiation?  If that's the case, how does it now which RCC function to call?  Eventually I will need to do RCCs again, but at least I can make some progress in other areas, such as proving my primitive prediction works beautifully.
« Last Edit: February 23, 2014, 02:41:29 AM by RFCsDriveMeNuts »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: I'm in RFC id hell right now. (Parameters don't match.)
« Reply #1 on: February 23, 2014, 12:55:26 PM »
RCCs and RFCs are totally different. RCC 0, 1 and 2 are used by TNManager (OnCreate0, OnCreate1, OnCreate2 functions, respectively).

RFC IDs are separate. TYNSyncRigidbody uses RFC ID 1 and TNAutoSync uses RFC 255, but that's it.

When you get a "parameters don't match" error it should tell you what it finds as well as what it expects, which might give you a hint regarding what's wrong. What does yours say?

RCCs need to be underneath the TNManager somewhere (limitation that's lifted in the current Pro version), but RFCs can be on any TNObject.

P.S. If you derive your script from TNBehaviour instead of MonoBehaviour, then you can use 'tno' instead of having your own 'myTNObject'.

RFCsDriveMeNuts

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: I'm in RFC id hell right now. (Parameters don't match.)
« Reply #2 on: February 23, 2014, 01:15:03 PM »
Thank for the reply, that clears up some questions.

Yes, I fixed several of the parameters don't match by checking signatures, but I was running around in circles with them, apparently because I screwed up the RCC.  I'd fix one, and another would break.  I even had your rigidbody auto sync script throwing it at one point, something I had never touched.

Do RFC IDs need to be unique per script, per project, per TNObject, per what?  I am pretty sure it's the latter, but just making sure I'm not entirely crazy (just mostly :-P).

TNBehavior, awesome shortcut!

My issue with the RCC was that I can't use 0, 1, and 2, correct?  If I use 3, everything should work as I expected above?  I was starting to think that all creation went through one function call, and it was up to you in the parameters to determine which is which.

Thank for taking time out of your Sunday to assist me (and others).  Lots of confusion in learning the library, but having written my fair share of my own networking libraries over the years, and I know yours is saving me an incredible amount of time!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: I'm in RFC id hell right now. (Parameters don't match.)
« Reply #3 on: February 23, 2014, 06:14:47 PM »
Yes, RCCs with IDs of 0, 1 and 2 are taken, but if you use 3 or higher it should work. I personally recommend 10 or higher though, just in case I add something later.

RCCs are per TNManager, so they are global.

RFCs are per-root-TNObject. So if you have a child TNObject, it counts as a part of the parent.