private void ReadPackets(bool multithreaded)
 {
     for (int i = 0; i < 2; i++)
     {
         uint pcubMsgSize = 0u;
         while (SteamNetworking.IsP2PPacketAvailable(out pcubMsgSize, i) && (NetGame.isNetStarting || NetGame.isNetStarted))
         {
             int    num          = NetStream.CalculateTierForSize((int)pcubMsgSize);
             byte[] array        = NetStream.AllocateBuffer(num);
             uint   pcubMsgSize2 = 0u;
             if (SteamNetworking.ReadP2PPacket(array, pcubMsgSize, out pcubMsgSize2, out CSteamID psteamIDRemote, i))
             {
                 if (array[0] == 0)
                 {
                     int num2 = array[1] * 256 * 256 + array[2] * 256 + array[3];
                     if (multipartBuffer == null)
                     {
                         int num3 = NetStream.CalculateSizeForTier(0) - 4;
                         multipartBufferTier   = NetStream.CalculateTierForSize((num2 + 1) * num3);
                         multipartBuffer       = NetStream.AllocateBuffer(multipartBufferTier);
                         multipartBufferOffset = 0u;
                     }
                     Array.Copy(array, 4L, multipartBuffer, multipartBufferOffset, pcubMsgSize2 - 4);
                     multipartBufferOffset += pcubMsgSize2 - 4;
                     NetStream.ReleaseBuffer(num, array);
                     if (num2 == 0)
                     {
                         num             = multipartBufferTier;
                         array           = multipartBuffer;
                         pcubMsgSize2    = multipartBufferOffset;
                         multipartBuffer = null;
                     }
                     else
                     {
                         array = null;
                     }
                 }
                 if (array != null)
                 {
                     if (multithreaded && i == 0)
                     {
                         lock (reliableQueueLock)
                         {
                             reliableQueue.Enqueue(new QueuedData
                             {
                                 steamIDRemote = psteamIDRemote,
                                 buffer        = array,
                                 bufferTier    = num,
                                 bytesRead     = (int)pcubMsgSize2
                             });
                         }
                         continue;
                     }
                     NetGame.instance.OnData(psteamIDRemote, array, num, (int)pcubMsgSize2);
                     NetStream.ReleaseBuffer(num, array);
                 }
             }