Пример #1
0
 /// <summary>
 /// Sends the MOTD.
 /// </summary>
 /// <param name="firstLine">The first line.</param>
 /// <param name="secondLine">The second line.</param>
 public void SendMOTD(string firstLine, string secondLine)
 {
     PacketQueue.WritePacket(new PacketIdentification(IsOperator)
     {
         FirstLine  = firstLine,
         SecondLine = secondLine
     });
 }
Пример #2
0
        /// <summary>
        /// Spawns the entity.
        /// </summary>
        /// <param name="p">The player.</param>
        public void SpawnEntity(NewPlayer p)
        {
            byte ID = 255;

            if (p != this)
            {
                ID = p.PlayerID;
            }

            PacketQueue.WritePacket(new PacketSpawnPlayer(ID, p.DisplayName, p.CurrentPosition, p.CurrentPitch, p.CurrentYaw));
            UpdatePos();
        }
Пример #3
0
        /// <summary>
        /// Sends the map.
        /// </summary>
        public void SendMap()
        {
            IsLoading = true;

            PacketQueue.WritePacket(new PacketLevelInitialize());

            byte[] data;
            using (var stream = new MemoryStream()) {
                using (var zipper = new GZipStream(stream, CompressionMode.Compress, true)) {
                    zipper.Write(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Level.Data.Length)), 0, 4);
                    zipper.Write(Level.Data, 0, Level.Data.Length);
                }
                data = stream.ToArray();
            }

            int sentBytes = 0;

            byte[] buffer = new byte[1024];

            while (sentBytes < data.Length)
            {
                int size = data.Length - sentBytes;
                if (size > 1024)
                {
                    size = 1024;
                }

                Array.Copy(data, sentBytes, buffer, 0, size);
                byte prog = (byte)(100 * sentBytes / data.Length);
                PacketQueue.WritePacket(new PacketLevelDataChunk((short)size, buffer, prog));

                sentBytes += size;
            }

            PacketQueue.WritePacket(new PacketLevelFinalize(Level.Size));
            IsLoading = false;
        }
Пример #4
0
 /// <summary>
 /// Sends the MOTD.
 /// </summary>
 public void SendMOTD()
 {
     PacketQueue.WritePacket(new PacketIdentification(IsOperator));
 }