Author Topic: [3.0.9] RequestSetChannelData sending ResponseSetChannelData to all players  (Read 1816 times)

Proton

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
  • Alberta, Canada
    • View Profile
    • Time Gamers
...even if they aren't in the channel. In TNGameServer.cs when processing Packet.RequestSetChannelData

  1. // Forward the packet to everyone in this channel
  2. for (int i = 0; i < mPlayerList.size; ++i)
  3. {
  4.         TcpPlayer tp = mPlayerList[i];
  5.         tp.SendTcpPacket(buffer);
  6. }

Should be more like this:
  1. // Forward the packet to everyone in this channel
  2. for (int i = 0; i < mPlayerList.size; ++i)
  3. {
  4.         TcpPlayer tp = mPlayerList[i];
  5.         // Don't send it back to the player that made the request
  6.         if( player == tp )
  7.                 continue;
  8.         // Only send to players in this channel
  9.         if( tp.IsInChannel(ch.id) == false )
  10.                 continue;
  11.  
  12.         tp.SendTcpPacket(buffer);
  13. }

It is handled client side (ignored), but can show up in a race condition when connecting. You could get a ResponseSetChannelData before ResponseID which causes the connection to fail. I haven't seen that happen, but it happened to a different custom packet that follows the same logic.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [3.0.9] RequestSetChannelData sending ResponseSetChannelData to all players
« Reply #1 on: September 06, 2017, 12:51:36 AM »
Interesting... thanks for letting me know! I'd fix it like so though:
  1. // Forward the packet to everyone in this channel
  2. for (int i = 0; i < ch.players.size; ++i)
  3. {
  4.         var tp = ch.players[i] as TcpPlayer;
  5.         tp.SendTcpPacket(buffer);
  6. }
Forwarding the Set back to the requesting player is intentional to avoid race conditions of it happening from multiple players, just in case.