Author Topic: JoinRandomChannel with no scene  (Read 2343 times)

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
JoinRandomChannel with no scene
« on: July 27, 2017, 08:00:57 PM »
Hey, is it possible to join a channel using TNManager.JoinRandomChannel without it loading a scene?

I only see the 1 overload which requires  a scene name, if I pass null I get an error of "No suitable channels found")

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: JoinRandomChannel with no scene
« Reply #1 on: July 27, 2017, 08:45:32 PM »
Yep, use TNManager.JoinChannel with a channelID of -1. This only creates a random channel, though, whereas JoinRandomChannel only joins an existing one. The reason you're getting that error with JoinRandomChannel must be because no open channels exist.

rxmarcus

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 62
    • View Profile
Re: JoinRandomChannel with no scene
« Reply #2 on: July 28, 2017, 02:31:39 PM »
This is frustrating as the code comment for this method states: "Join a random open game channel or create a new one"

So it SHOULD create a new one if one doesn't exist, and it does if I pass a string for the scene, it's just if I pass null that it has issues. This ruins the usefulness of this method as I want to use it for quickplay on my game server, but with how its now acting I'd have to request a list of channels for the server, see if there are any, if so then I can call that method, otherwise I need to just use JoinChannel(0);

@ArenMook, can this method be fixed so that I can pass null for the scene like you can on other JoinChannel methods?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: JoinRandomChannel with no scene
« Reply #3 on: August 03, 2017, 04:26:45 AM »
Sounds reasonable. I think that code dates back to when a level name was required, and it wasn't possible to pass null. I'll remove it, but you can also do it on your end and recompile the server. Just comment out that entire section in TNGameServer.cs, line 1021:
  1.                                 // If no level name has been specified and no channels were found, we're done
  2.                                 /*if (randomLevel && channelID == -1)
  3.                                 {
  4.                                         BinaryWriter writer = BeginSend(Packet.ResponseJoinChannel);
  5.                                         writer.Write(channelID);
  6.                                         writer.Write(false);
  7.                                         writer.Write("No suitable channels found");
  8.                                         EndSend(true, player);
  9.                                         return;
  10.                                 }*/