Author Topic: Cannot call RFC before TNObject is created?  (Read 3519 times)

Masaaki

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Cannot call RFC before TNObject is created?
« on: August 30, 2013, 06:27:47 PM »
I'm having an issue with my local tests of TNet. I'm trying to call an RFC on a TNObject, which should work locally without having to start up a server right? Except it triggers this error:

Trying to execute a function 1 on TNObject #0 before it has been created

I'm instantiating this object through a custom object creation handler, CustomCreateHandler.Create( ... ).
After some debugging it seems the object is never registered with TNObject.mDictionary, and it seems to be due to the ID being 0. But I was under the impression that this shouldn't matter if the object is dynamically instantiated?

Any help?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cannot call RFC before TNObject is created?
« Reply #1 on: August 31, 2013, 12:38:49 PM »
Hmm... What is inside your custom creation function? RFCs get called on objects as-is without going through finding them, so the object ID is irrelevant in offline mode.

Masaaki

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Cannot call RFC before TNObject is created?
« Reply #2 on: August 31, 2013, 01:01:23 PM »
Hmm... What is inside your custom creation function? RFCs get called on objects as-is without going through finding them, so the object ID is irrelevant in offline mode.

That doesn't appear to be the case. Following the functions:

I call Send
Send calls SendRFC
SendRFC sets a local 'executeLocally' flag
Later in the function it checks this flag, and if true calls TNObject.FindAndExecute passing the object ID, rfc ID (or name), and params.

My custom create handler isn't affecting anything, if I switch to just straight TNManager.Create I still get the issue.

Here's something odd. I checked the Example 2 scene, which spawns cubes. The cube prefab has ID 8 assigned. The first cube that spawns has ID 8, the next one has 9, etc. BUT if I let all of the cubes delete themselves and then spawn another one, it has ID 8 again. So if I had spawned 5 cubes the first time, the cubes had ID 8, 9, 10, 11, 12. If I let all of the cubes delete, then spawn another five cubes, they have IDs 8, 13, 14, 15, 16. It seems that the first object to be spawned, if there are no other dynamic objects in the scene, will get the ID of the prefab rather than an actually unique ID. I don't know if this is intended behavior or not, but it seems that assigning a non-zero ID to my dynamic object fixes the issue with not being able to call RFCs.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cannot call RFC before TNObject is created?
« Reply #3 on: August 31, 2013, 01:19:27 PM »
I'm still at Vancouver right now but I will have a look into it when I get home.

Masaaki

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Cannot call RFC before TNObject is created?
« Reply #4 on: September 02, 2013, 05:46:38 PM »
In case it helps, I noticed object ID assignment behaves differently depending on whether TNet is connected to a server or not. Connecting to a server, it seems to properly generate unique object IDs. When not connected, the behavior I mentioned in the last post happens.

EDIT: After some investigation, the behavior I mentioned appears to be a result of the UniqueCheck() which occurs in the editor. That's why the first object has the same ID as defined in the prefab - because UniqueCheck() determines that the ID is unique.
« Last Edit: September 02, 2013, 09:29:27 PM by Masaaki »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cannot call RFC before TNObject is created?
« Reply #5 on: September 03, 2013, 03:43:23 AM »
I fixed this locally earlier today, and you will see it fixed in the next update.