Author Topic: Saved RFCs arriving out of order  (Read 2794 times)

tylerglaiel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Saved RFCs arriving out of order
« on: January 24, 2014, 06:49:24 PM »
Hello! I found an issue with the way saved RFCs are called when a new player joins a channel.


I have a dynamically created object X (created with TNManager.Create)

For the sake of testing I have an RFC that does nothing but send incremental integers every frame, (frame 1 it sends 1, frame 2 it sends 2)

When a player joins the channel, he does not receive the first few hundred integers first (depending on how long the server has been running before he joins).

I'm digging around in the source code for TNet but can't seem to find out exactly where the issue is

Any help would be appreciated

Thanks

tylerglaiel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Saved RFCs arriving out of order
« Reply #1 on: January 24, 2014, 07:15:15 PM »
Oh, it only saves the most recent call of an RFC? What if I don't want this functionality?

tylerglaiel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Saved RFCs arriving out of order
« Reply #2 on: January 24, 2014, 07:23:45 PM »
Fixed:

commented out

  1. for (int i = 0; i < rfcs.size; ++i)
  2.                 {
  3.                         RFC r = rfcs[i];
  4.                        
  5.                         if (r.id == inID && r.funcName == funcName)
  6.                         {
  7.                                 if (r.buffer != null) r.buffer.Recycle();
  8.                                 r.buffer = buffer;
  9.                                 return;
  10.                         }
  11.                 }

in TNChannel::CreateRFC

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Saved RFCs arriving out of order
« Reply #3 on: January 25, 2014, 02:45:13 AM »
Don't do that. Only the latest state should be kept. If you want to keep a flexible list, then do just that -- pass an array to your persistent RFC call -- and each time you modify it, simply call the RFC function again with the updated list.

tylerglaiel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Saved RFCs arriving out of order
« Reply #4 on: January 25, 2014, 12:47:10 PM »
I have a destructible level. I send messages that destroy tiles in a certain region, sending the entire level at once every time would be impractical. Making the modification I put above fixed it all (and I changed DeleteRFC to delete all of them correctly instead of just one)

Would be nice to at least have it as an option, is there a reason its disallowed?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Saved RFCs arriving out of order
« Reply #5 on: January 25, 2014, 04:05:13 PM »
What does a destructible level have to do with keeping all RFC calls?

When you destroy something via TNManager.Destroy, all of its RFCs go away too, and if you dynamically created this object, the "create" call also goes away -- so new players will never even know that the object existed in the first place.

Instead of sending messages that destroy regions, use TNManager.Destroy. Keeping a stack of RFCs instead of only the latest is a very strange thing to do. Think about it... player move updates, sent say... 10 times per second for 10 minutes -- that's 10*60*10 = 6000 RFC calls in a stack that must be sent to all new players. Why do that, if only the very last update actually matters? The fact that Unity's built-in networking does it shows just how little they thought things through in a real-world scenario.

tylerglaiel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Saved RFCs arriving out of order
« Reply #6 on: January 25, 2014, 08:29:40 PM »
Tiles are not individual game objects so I can't do it that way. There are 16384 tiles [32x32x16] in an average sized level in my game, so I can't have them be individual game objects if I wanted to.

Quote
Think about it... player move updates, sent say... 10 times per second for 10 minutes -- that's 10*60*10 = 6000 RFC calls in a stack that must be sent to all new players. Why do that, if only the very last update actually matters?

I agree it doesn't work well for player updates, but there's plenty of other spots it does work well for