Exemplo n.º 1
0
        public bool SectionRange(int size, int firstX, int firstY)
        {
            for (int i = 0; i < 4; i++)
            {
                int x = firstX;
                int y = firstY;
                switch (i)
                {
                case 1:
                    x += size;
                    break;

                case 2:
                    y += size;
                    break;

                case 3:
                    x += size;
                    y += size;
                    break;
                }
                int sectionX = Netplay.GetSectionX(x);
                int sectionY = Netplay.GetSectionY(y);
                if (this.tileSection[sectionX, sectionY])
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 private static void ClientLoopSetup(RemoteAddress address)
 {
     Netplay.ResetNetDiag();
     Main.ServerSideCharacter = false;
     if (Main.rand == null)
     {
         Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
     }
     Main.player[Main.myPlayer].hostile = false;
     Main.clientPlayer = (Player)Main.player[Main.myPlayer].clientClone();
     for (int index = 0; index < (int)byte.MaxValue; ++index)
     {
         if (index != Main.myPlayer)
         {
             Main.player[index] = new Player();
         }
     }
     Main.netMode  = 1;
     Main.menuMode = 14;
     if (!Main.autoPass)
     {
         Main.statusText = Language.GetTextValue("Net.ConnectingTo", (object)address.GetFriendlyName());
     }
     Netplay.disconnect            = false;
     Netplay.Connection            = new RemoteServer();
     Netplay.Connection.ReadBuffer = new byte[1024];
 }
Exemplo n.º 3
0
 private static void OpenPort()
 {
     Netplay.portForwardIP   = Netplay.GetLocalIPAddress();
     Netplay.portForwardPort = Netplay.ListenPort;
     if (Netplay.upnpnat == null)
     {
         Netplay.upnpnat  = (UPnPNAT)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1")));
         Netplay.mappings = Netplay.upnpnat.StaticPortMappingCollection;
     }
     if (Netplay.mappings == null)
     {
         return;
     }
     foreach (IStaticPortMapping mapping in Netplay.mappings)
     {
         if (mapping.InternalPort == Netplay.portForwardPort && mapping.InternalClient == Netplay.portForwardIP && mapping.Protocol == "TCP")
         {
             Netplay.portForwardOpen = true;
         }
     }
     if (Netplay.portForwardOpen)
     {
         return;
     }
     // ISSUE: reference to a compiler-generated method
     Netplay.mappings.Add(Netplay.portForwardPort, "TCP", Netplay.portForwardPort, Netplay.portForwardIP, true, "Terraria Server");
     Netplay.portForwardOpen = true;
 }
Exemplo n.º 4
0
        private static void OpenPort(int port)
        {
            string localIpAddress = Netplay.GetLocalIPAddress();

            if (Netplay._upnpnat == null)
            {
                Netplay._upnpnat  = (UPnPNAT)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1")));
                Netplay._mappings = Netplay._upnpnat.StaticPortMappingCollection;
            }
            if (Netplay._mappings == null)
            {
                return;
            }
            bool flag = false;

            foreach (IStaticPortMapping mapping in Netplay._mappings)
            {
                if (mapping.InternalPort == port && mapping.InternalClient == localIpAddress && mapping.Protocol == "TCP")
                {
                    flag = true;
                }
            }
            if (flag)
            {
                return;
            }
            // ISSUE: reference to a compiler-generated method
            Netplay._mappings.Add(port, "TCP", port, localIpAddress, true, "Terraria Server");
        }
Exemplo n.º 5
0
        // Token: 0x06000140 RID: 320 RVA: 0x00029B00 File Offset: 0x00027D00
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num > 0)
            {
                int num2 = num;
                NetMessage.SendData(9, playerIndex, -1, Lang.inter[44].ToNetworkText(), num2, 0f, 0f, 0f, 0, 0, 0);
                Netplay.Clients[playerIndex].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
                Netplay.Clients[playerIndex].StatusMax  += num2;
                for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
                {
                    for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                    {
                        if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[k, l])
                        {
                            NetMessage.SendSection(playerIndex, k, l, false);
                            NetMessage.SendData(11, playerIndex, -1, null, k, (float)l, (float)k, (float)l, 0, 0, 0);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 public bool SectionRange(int size, int firstX, int firstY)
 {
     for (int i = 0; i < 4; i++)
     {
         int num  = firstX;
         int num2 = firstY;
         if (i == 1)
         {
             num += size;
         }
         if (i == 2)
         {
             num2 += size;
         }
         if (i == 3)
         {
             num  += size;
             num2 += size;
         }
         int sectionX = Netplay.GetSectionX(num);
         int sectionY = Netplay.GetSectionY(num2);
         if (this.tileSection[sectionX, sectionY])
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 7
0
 public static void SetRemoteIPAsync(string remoteAddress, Action successCallBack)
 {
     try
     {
         IPAddress address;
         if (IPAddress.TryParse(remoteAddress, out address))
         {
             Netplay.ServerIP     = address;
             Netplay.ServerIPText = address.ToString();
             successCallBack();
         }
         else
         {
             Netplay.InvalidateAllOngoingIPSetAttempts();
             Dns.BeginGetHostAddresses(remoteAddress, new AsyncCallback(Netplay.SetRemoteIPAsyncCallback), (object)new Netplay.SetRemoteIPRequestInfo()
             {
                 RequestId       = Netplay._currentRequestId,
                 SuccessCallback = successCallBack,
                 RemoteAddress   = remoteAddress
             });
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 8
0
 private static void CleanupServer()
 {
     Netplay.StopListening();
     try
     {
         Netplay.ClosePort(Netplay.ListenPort);
     }
     catch
     {
     }
     for (int index = 0; index < 256; ++index)
     {
         Netplay.Clients[index].Reset();
     }
     if (Main.menuMode != 15)
     {
         Main.netMode  = 0;
         Main.menuMode = 10;
         WorldFile.SaveWorld();
         Main.menuMode = 0;
     }
     else
     {
         Main.netMode = 0;
     }
     Main.myPlayer = 0;
 }
Exemplo n.º 9
0
 public bool SectionRange(int size, int firstX, int firstY)
 {
     for (int index = 0; index < 4; ++index)
     {
         int x = firstX;
         int y = firstY;
         if (index == 1)
         {
             x += size;
         }
         if (index == 2)
         {
             y += size;
         }
         if (index == 3)
         {
             x += size;
             y += size;
         }
         if (this.TileSections[Netplay.GetSectionX(x), Netplay.GetSectionY(y)])
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 10
0
 private static void ClientLoopSetup(RemoteAddress address)
 {
     Netplay.ResetNetDiag();
     Main.ServerSideCharacter = false;
     if (Main.rand == null)
     {
         Main.rand = new Random((int)DateTime.Now.Ticks);
     }
     if (WorldGen.genRand == null)
     {
         WorldGen.genRand = new Random((int)DateTime.Now.Ticks);
     }
     Main.player[Main.myPlayer].hostile = false;
     Main.clientPlayer = (Player)Main.player[Main.myPlayer].clientClone();
     for (int i = 0; i < 255; i++)
     {
         if (i != Main.myPlayer)
         {
             Main.player[i] = new Player();
         }
     }
     Main.netMode  = 1;
     Main.menuMode = 14;
     if (!Main.autoPass)
     {
         Main.statusText = "Connecting to " + address.GetFriendlyName();
     }
     Netplay.disconnect            = false;
     Netplay.Connection            = new RemoteServer();
     Netplay.Connection.ReadBuffer = new byte[1024];
 }
Exemplo n.º 11
0
        private static void OnConnectionAccepted(ISocket client)
        {
            int num = Netplay.FindNextOpenClientSlot();

            if (num != -1)
            {
                Netplay.Clients[num].Socket = client;
                Netplay.Clients[num].sendQueue.StartThread();

                Console.WriteLine(client.GetRemoteAddress() + " is connecting to slot {0}...", num);
            }
            else
            {
                using (var stream = new MemoryStream())
                {
                    using (var writer = new BinaryWriter(stream))
                    {
                        writer.Write((short)0);
                        writer.Write((byte)2);
                        writer.Write("Server is full.");
                        short position = (short)writer.BaseStream.Position;
                        writer.BaseStream.Position = 0L;
                        writer.Write((short)position);
                        byte[] data = stream.ToArray();
                        client.AsyncSend(data, 0, data.Length, delegate { });
                    }
                }
                client.Close();
            }
        }
Exemplo n.º 12
0
        public static void SocialClientLoop(object threadContext)
        {
            ISocket socket = (ISocket)threadContext;

            Netplay.ClientLoopSetup(socket.GetRemoteAddress());
            Netplay.Connection.Socket = socket;
        }
Exemplo n.º 13
0
        public static void CheckSection(int who, Vector2 position)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - 1; i < sectionX + 2; i++)
            {
                for (int j = sectionY - 1; j < sectionY + 2; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.serverSock[who].tileSection[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num > 0)
            {
                int num2 = num * 150;
                NetMessage.SendData(9, who, -1, "Receiving tile data", num2, 0f, 0f, 0f, 0);
                Netplay.serverSock[who].statusText2 = "is receiving tile data";
                Netplay.serverSock[who].statusMax  += num2;
                for (int k = sectionX - 1; k < sectionX + 2; k++)
                {
                    for (int l = sectionY - 1; l < sectionY + 2; l++)
                    {
                        if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.serverSock[who].tileSection[k, l])
                        {
                            NetMessage.SendSection(who, k, l);
                            NetMessage.SendData(11, who, -1, "", k, (float)l, (float)k, (float)l, 0);
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public static void TcpClientLoop(object threadContext)
        {
            Netplay.ClientLoopSetup((RemoteAddress) new TcpAddress(Netplay.ServerIP, Netplay.ListenPort));
            Main.menuMode = 14;
            bool flag = true;

            while (flag)
            {
                flag = false;
                try
                {
                    Netplay.Connection.Socket.Connect((RemoteAddress) new TcpAddress(Netplay.ServerIP, Netplay.ListenPort));
                    flag = false;
                }
                catch
                {
                    if (!Netplay.disconnect)
                    {
                        if (Main.gameMenu)
                        {
                            flag = true;
                        }
                    }
                }
            }
            Netplay.InnerClientLoop();
        }
Exemplo n.º 15
0
 private static void JoinSession()
 {
     session = Netplay.availableSessions[selectedSession];
     Netplay.StopFindingSessions();
     UI.main.SetMenu(MenuMode.NETPLAY);
     UI.main.statusText = Lang.menu[80];
     Netplay.StartClient();
 }
Exemplo n.º 16
0
 public static void StartBroadCasting()
 {
     if (Netplay.broadcastThread != null)
     {
         Netplay.StopBroadCasting();
     }
     Netplay.broadcastThread = new Thread(new ThreadStart(Netplay.BroadcastThread));
     Netplay.broadcastThread.Start();
 }
Exemplo n.º 17
0
 public static void StartServer()
 {
     Netplay.InitializeServer();
     Netplay._serverThread = new Thread(new ThreadStart(Netplay.ServerLoop))
     {
         IsBackground = true,
         Name         = "Server Loop Thread"
     };
     Netplay._serverThread.Start();
 }
Exemplo n.º 18
0
        // Token: 0x06000159 RID: 345 RVA: 0x0002AA6C File Offset: 0x00028C6C
        private static void OnConnectionAccepted(ISocket client)
        {
            int num = Netplay.FindNextOpenClientSlot();

            if (num != -1)
            {
                Netplay.Clients[num].Reset();
                Netplay.Clients[num].Socket = client;
                Console.WriteLine(Language.GetTextValue("Net.ClientConnecting", client.GetRemoteAddress()));
            }
            if (Netplay.FindNextOpenClientSlot() == -1)
            {
                Netplay.StopListening();
            }
        }
Exemplo n.º 19
0
        private static void OnConnectionAccepted(ISocket client)
        {
            int nextOpenClientSlot = Netplay.FindNextOpenClientSlot();

            if (nextOpenClientSlot != -1)
            {
                Netplay.Clients[nextOpenClientSlot].Socket = client;
                Console.WriteLine((string)(object)client.GetRemoteAddress() + (object)" is connecting...");
            }
            if (Netplay.FindNextOpenClientSlot() != -1)
            {
                return;
            }
            Netplay.StopListening();
        }
Exemplo n.º 20
0
        private static void ServerLoop()
        {
            int num = 0;

            Netplay.StartBroadCasting();
            while (!Netplay.Disconnect)
            {
                Netplay.StartListeningIfNeeded();
                Netplay.UpdateConnectedClients();
                num = (num + 1) % 10;
                Thread.Sleep(num == 0 ? 1 : 0);
            }
            Netplay.StopBroadCasting();
            Netplay.CleanupServer();
        }
Exemplo n.º 21
0
        private static void OnConnectionAccepted(ISocket client)
        {
            int num = Netplay.FindNextOpenClientSlot();

            if (num != -1)
            {
                Netplay.Clients[num].Reset();
                Netplay.Clients[num].Socket = client;
                Console.WriteLine(client.GetRemoteAddress() + " is connecting...");
            }
            if (Netplay.FindNextOpenClientSlot() == -1)
            {
                Netplay.StopListening();
            }
        }
Exemplo n.º 22
0
        private static void OnConnectionAccepted(ISocket client)
        {
            var nextOpenClientSlot = Netplay.FindNextOpenClientSlot();

            if (nextOpenClientSlot != -1)
            {
                Netplay.Clients[nextOpenClientSlot].Reset();
                Netplay.Clients[nextOpenClientSlot].Socket = client;
                Console.WriteLine(Language.GetTextValue("Net.ClientConnecting", (object)client.GetRemoteAddress()));
            }

            if (Netplay.FindNextOpenClientSlot() != -1)
            {
                return;
            }
            Netplay.StopListening();
        }
Exemplo n.º 23
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int index1   = playerIndex;
            int sectionX = Netplay.GetSectionX((int)((double)position.X / 16.0));
            int sectionY = Netplay.GetSectionY((int)((double)position.Y / 16.0));
            int num      = 0;

            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int index3 = sectionY - fluff; index3 < sectionY + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        ++num;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int number = num;

            NetMessage.SendData(9, index1, -1, Lang.inter[44].ToNetworkText(), number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            Netplay.Clients[index1].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
            Netplay.Clients[index1].StatusMax  += number;
            RemoteClient._pendingSectionFraming.Clear();
            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int index3 = sectionY - fluff; index3 < sectionY + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        NetMessage.SendSection(index1, index2, index3, false);
                        RemoteClient._pendingSectionFraming.Add(new Point(index2, index3));
                    }
                }
            }
            foreach (Point point in RemoteClient._pendingSectionFraming)
            {
                NetMessage.SendData(11, index1, -1, (NetworkText)null, point.X, (float)point.Y, (float)point.X, (float)point.Y, 0, 0, 0);
            }
        }
Exemplo n.º 24
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            var index1    = playerIndex;
            var sectionX  = Netplay.GetSectionX((int)((double)position.X / 16.0));
            var sectionY1 = Netplay.GetSectionY((int)((double)position.Y / 16.0));
            var num       = 0;

            for (var index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (var index3 = sectionY1 - fluff; index3 < sectionY1 + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) &&
                        !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        ++num;
                    }
                }
            }

            if (num <= 0)
            {
                return;
            }
            var number = num;

            NetMessage.SendData(9, index1, -1, Lang.inter[44].ToNetworkText(), number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            Netplay.Clients[index1].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
            Netplay.Clients[index1].StatusMax  += number;
            for (var index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (var sectionY2 = sectionY1 - fluff; sectionY2 < sectionY1 + fluff + 1; ++sectionY2)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX &&
                        (sectionY2 >= 0 && sectionY2 < Main.maxSectionsY) &&
                        !Netplay.Clients[index1].TileSections[index2, sectionY2])
                    {
                        NetMessage.SendSection(index1, index2, sectionY2, false);
                        NetMessage.SendData(11, index1, -1, (NetworkText)null, index2, (float)sectionY2,
                                            (float)index2, (float)sectionY2, 0, 0, 0);
                    }
                }
            }
        }
Exemplo n.º 25
0
 private static void InitializeServer()
 {
     Netplay.ResetNetDiag();
     if (Main.rand == null)
     {
         Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
     }
     Main.myPlayer      = (int)byte.MaxValue;
     Netplay.ServerIP   = IPAddress.Any;
     Main.menuMode      = 14;
     Main.statusText    = Lang.menu[8].Value;
     Main.netMode       = 2;
     Netplay.Disconnect = false;
     for (int index = 0; index < 256; ++index)
     {
         Netplay.Clients[index] = new RemoteClient();
         Netplay.Clients[index].Reset();
         Netplay.Clients[index].Id         = index;
         Netplay.Clients[index].ReadBuffer = new byte[1024];
     }
     Netplay.TcpListener = (ISocket) new TcpSocket();
     if (!Netplay.Disconnect)
     {
         if (!Netplay.StartListening())
         {
             Main.menuMode      = 15;
             Main.statusText    = Language.GetTextValue("Error.TriedToRunServerTwice");
             Netplay.Disconnect = true;
         }
         Main.statusText = Language.GetTextValue("CLI.ServerStarted");
     }
     if (!Netplay.UseUPNP)
     {
         return;
     }
     try
     {
         Netplay.OpenPort(Netplay.ListenPort);
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 26
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int num2 = num;

            NetMessage.SendData(9, playerIndex, -1, Lang.inter[44].ToNetworkText(), num2);
            Netplay.Clients[playerIndex].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
            Netplay.Clients[playerIndex].StatusMax  += num2;
            _pendingSectionFraming.Clear();
            for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
            {
                for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                {
                    if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[k, l])
                    {
                        NetMessage.SendSection(playerIndex, k, l);
                        _pendingSectionFraming.Add(new Point(k, l));
                    }
                }
            }
            foreach (Point item in _pendingSectionFraming)
            {
                NetMessage.SendData(11, playerIndex, -1, null, item.X, item.Y, item.X, item.Y);
            }
        }
Exemplo n.º 27
0
        private static void OnConnectionAccepted(ISocket client)
        {
            int nextOpenClientSlot = Netplay.FindNextOpenClientSlot();

            if (nextOpenClientSlot != -1)
            {
                Netplay.Clients[nextOpenClientSlot].Reset();
                Netplay.Clients[nextOpenClientSlot].Socket = client;
            }
            else
            {
                lock (Netplay.fullBuffer)
                    Netplay.KickClient(client, NetworkText.FromKey("CLI.ServerIsFull"));
            }
            if (Netplay.FindNextOpenClientSlot() != -1)
            {
                return;
            }
            Netplay.StopListening();
            Netplay.IsListening = false;
        }
Exemplo n.º 28
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int num      = playerIndex;
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num1     = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[num].TileSections[i, j])
                    {
                        num1++;
                    }
                }
            }
            if (num1 > 0)
            {
                int num2 = num1;
                Netplay.Clients[num].StatusText2 = "is receiving tile data";
                RemoteClient clients = Netplay.Clients[num];
                clients.StatusMax = clients.StatusMax + num2;

                NetMessage.SendData(9, num, -1, Lang.inter[44], num2, 0f, 0f, 0f, 0, 0, 0);

                for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
                {
                    for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                    {
                        if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[num].TileSections[k, l])
                        {
                            NetMessage.SendSection(num, k, l, false);
                            NetMessage.SendData(11, num, -1, "", k, (float)l, (float)k, (float)l, 0, 0, 0);
                        }
                    }
                }
            }
        }
Exemplo n.º 29
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int index1    = playerIndex;
            int sectionX  = Netplay.GetSectionX((int)((double)position.X / 16.0));
            int sectionY1 = Netplay.GetSectionY((int)((double)position.Y / 16.0));
            int num       = 0;

            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int index3 = sectionY1 - fluff; index3 < sectionY1 + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        ++num;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int number = num;

            NetMessage.SendData(9, index1, -1, Lang.inter[44], number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            Netplay.Clients[index1].StatusText2 = "is receiving tile data";
            Netplay.Clients[index1].StatusMax  += number;
            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int sectionY2 = sectionY1 - fluff; sectionY2 < sectionY1 + fluff + 1; ++sectionY2)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (sectionY2 >= 0 && sectionY2 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, sectionY2])
                    {
                        NetMessage.SendSection(index1, index2, sectionY2, false);
                        NetMessage.SendData(11, index1, -1, "", index2, (float)sectionY2, (float)index2, (float)sectionY2, 0, 0, 0);
                    }
                }
            }
        }
Exemplo n.º 30
0
        private static void ClosePort(int port)
        {
            string localIpAddress = Netplay.GetLocalIPAddress();
            bool   flag           = false;

            if (Netplay._mappings == null)
            {
                return;
            }
            foreach (IStaticPortMapping mapping in Netplay._mappings)
            {
                if (mapping.InternalPort == port && mapping.InternalClient == localIpAddress && mapping.Protocol == "TCP")
                {
                    flag = true;
                }
            }
            if (flag)
            {
                return;
            }
            // ISSUE: reference to a compiler-generated method
            Netplay._mappings.Remove(port, "TCP");
        }