示例#1
0
        public static ServerListEntry Create(ref StackDataReader p)
        {
            ServerListEntry entry = new ServerListEntry()
            {
                Index       = p.ReadUInt16BE(),
                Name        = p.ReadASCII(32, true),
                PercentFull = p.ReadUInt8(),
                Timezone    = p.ReadUInt8(),
                Address     = p.ReadUInt32BE()
            };

            // some server sends invalid ip.
            try
            {
                entry._ipAddress = new IPAddress
                                   (
                    new byte[]
                {
                    (byte)((entry.Address >> 24) & 0xFF),
                    (byte)((entry.Address >> 16) & 0xFF),
                    (byte)((entry.Address >> 8) & 0xFF),
                    (byte)(entry.Address & 0xFF)
                }
                                   );
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }

            entry._pinger.PingCompleted += entry.PingerOnPingCompleted;

            return(entry);
        }
示例#2
0
        public void ServerListReceived(ref StackDataReader p)
        {
            byte   flags = p.ReadUInt8();
            ushort count = p.ReadUInt16BE();

            DisposeAllServerEntries();
            Servers = new ServerListEntry[count];

            for (ushort i = 0; i < count; i++)
            {
                Servers[i] = ServerListEntry.Create(ref p);
            }

            CurrentLoginStep = LoginSteps.ServerSelection;

            if (CanAutologin)
            {
                if (Servers.Length != 0)
                {
                    int index = GetServerIndexFromSettings();

                    SelectServer((byte)Servers[index].Index);
                }
            }
        }
示例#3
0
        public void HandleRelayServerPacket(ref StackDataReader p)
        {
            long   ip   = p.ReadUInt32LE(); // use LittleEndian here
            ushort port = p.ReadUInt16BE();
            uint   seed = p.ReadUInt32BE();

            NetClient.LoginSocket.Disconnect();
            EncryptionHelper.Initialize(false, seed, (ENCRYPTION_TYPE)Settings.GlobalSettings.Encryption);

            NetClient.Socket.Connect(new IPAddress(ip), port)
            .ContinueWith
            (
                t =>
            {
                if (!t.IsFaulted)
                {
                    NetClient.Socket.EnableCompression();

                    unsafe
                    {
                        Span <byte> b = stackalloc byte[4] {
                            (byte)(seed >> 24), (byte)(seed >> 16), (byte)(seed >> 8), (byte)seed
                        };
                        StackDataWriter writer = new StackDataWriter(b);
                        NetClient.Socket.Send(writer.AllocatedBuffer, writer.BytesWritten, true, true);
                        writer.Dispose();
                    }

                    NetClient.Socket.Send_SecondLogin(Account, Password, seed);
                }
            },
                TaskContinuationOptions.ExecuteSynchronously
            );
        }
示例#4
0
        public static PopupMenuData Parse(ref StackDataReader p)
        {
            ushort mode        = p.ReadUInt16BE();
            bool   isNewCliloc = mode >= 2;
            uint   serial      = p.ReadUInt32BE();
            byte   count       = p.ReadUInt8();

            PopupMenuItem[] items = new PopupMenuItem[count];

            for (int i = 0; i < count; i++)
            {
                ushort hue = 0xFFFF, replaced = 0;
                int    cliloc;
                ushort index, flags;

                if (isNewCliloc)
                {
                    cliloc = (int)p.ReadUInt32BE();
                    index  = p.ReadUInt16BE();
                    flags  = p.ReadUInt16BE();
                }
                else
                {
                    index  = p.ReadUInt16BE();
                    cliloc = p.ReadUInt16BE() + 3000000;
                    flags  = p.ReadUInt16BE();

                    if ((flags & 0x84) != 0)
                    {
                        p.Skip(2);
                    }

                    if ((flags & 0x40) != 0)
                    {
                        p.Skip(2);
                    }

                    if ((flags & 0x20) != 0)
                    {
                        replaced = (ushort)(p.ReadUInt16BE());
                    }
                }

                if ((flags & 0x01) != 0)
                {
                    hue = 0x0386;
                }

                items[i] = new PopupMenuItem
                           (
                    cliloc,
                    index,
                    hue,
                    replaced,
                    flags
                           );
            }

            return(new PopupMenuData(serial, items));
        }
示例#5
0
        private static void HandleStatusUpdate(ref StackDataReader p)
        {
            if (World.Player == null)
            {
                return;
            }

            var serial = p.ReadUInt32BE(); // In-case we decide to send this packet to describe other mobiles

            World.Player.Hunger             = (short)p.ReadUInt16BE();
            World.Player.HealBonus          = (short)p.ReadUInt16BE();
            World.Player.MagicImmunity      = (short)p.ReadUInt16BE();
            World.Player.MagicReflect       = (short)p.ReadUInt16BE();
            World.Player.PhysicalProtection = (short)p.ReadUInt16BE();
            World.Player.PoisonProtection   = (short)p.ReadUInt16BE();
            World.Player.FireProtection     = (short)p.ReadUInt16BE();
            World.Player.WaterProtection    = (short)p.ReadUInt16BE();
            World.Player.AirProtection      = (short)p.ReadUInt16BE();
            World.Player.EarthProtection    = (short)p.ReadUInt16BE();
            World.Player.NecroProtection    = (short)p.ReadUInt16BE();
            World.Player.ShortTermMurders   = (short)p.ReadUInt16BE();
            World.Player.LongTermMurders    = (short)p.ReadUInt16BE();
            World.Player.DamageMin          = (short)p.ReadUInt16BE();
            World.Player.DamageMax          = (short)p.ReadUInt16BE();
        }