Ejemplo n.º 1
0
        public override void DisplayTo(VisibleObject obj)
        {
            if (Hidden || Stealth)
            {
                return;
            }

            if (obj is Player)
            {
                var player = (obj as Player);
                var client = player.Client;

                var p = new ServerPacket(0x07);
                p.WriteUInt16(1);
                p.WriteUInt16((ushort)Point.X);
                p.WriteUInt16((ushort)Point.Y);
                p.WriteUInt32((uint)ID);
                p.WriteUInt16((ushort)((Polymorphed ? PolymorphForm : Sprite) + 0x4000));
                p.WriteByte(0); // random 1
                p.WriteByte(0); // random 2
                p.WriteByte(0); // random 3
                p.WriteByte(0); // unknown a
                p.WriteByte((byte)Direction);
                p.WriteByte(0); // unknown b
                p.WriteByte(Cursed);
                p.WriteByte(0); // unknown d
                p.WriteByte((byte)Type);
                p.WriteString8(Name);

                client.Enqueue(p);
            }
        }
Ejemplo n.º 2
0
        public void Redirect(Server.Redirection r)
        {
            r.DestinationServer.ExpectedRedirects.Add(r.ID, r);

            var ipEndPoint = r.DestinationServer.EndPoint;

            byte[] addressBytes = ipEndPoint.Address.GetAddressBytes();

            if (IPAddress.IsLoopback(IPAddress) || IPAddress.ToString().StartsWith("192.168"))
            {
                addressBytes = IPAddress.Parse("192.168.0.42").GetAddressBytes();
            }

            Array.Reverse(addressBytes);

            var p = new ServerPacket(0x03);

            p.Write(addressBytes);
            p.WriteUInt16((ushort)ipEndPoint.Port);
            p.WriteByte((byte)(r.EncryptionParameters.PrivateKey.Length + Encoding.GetEncoding(949).GetBytes(r.Name).Length + 7));
            p.WriteByte(r.EncryptionParameters.Seed);
            p.WriteByte((byte)r.EncryptionParameters.PrivateKey.Length);
            p.Write(r.EncryptionParameters.PrivateKey);
            p.WriteString8(r.Name);
            p.WriteUInt32(r.ID);
            Enqueue(p);
        }
Ejemplo n.º 3
0
 private void MsgHandler_RequestMetafile(Client client, ClientPacket msg)
 {
     if (!msg.ReadBoolean())
     {
         string fileName = msg.ReadString(msg.ReadByte());
         if (GameServer.MetafileDatabase.ContainsKey(fileName))
         {
             var p = new ServerPacket(0x6F);
             p.WriteByte(0);
             p.WriteString8(fileName);
             p.WriteUInt32(GameServer.MetafileDatabase[fileName].Checksum);
             p.WriteUInt16((ushort)GameServer.MetafileDatabase[fileName].RawData.Length);
             p.Write(GameServer.MetafileDatabase[fileName].RawData);
             client.Enqueue(p);
         }
     }
     else
     {
         var p = new ServerPacket(0x6F);
         p.WriteByte(1);
         p.WriteUInt16((ushort)GameServer.MetafileDatabase.Count);
         foreach (var kvp in GameServer.MetafileDatabase)
         {
             p.WriteString8(kvp.Value.Name);
             p.WriteUInt32(kvp.Value.Checksum);
         }
         client.Enqueue(p);
     }
 }
Ejemplo n.º 4
0
        private void MsgHandler_ClientJoin(Client client, ClientPacket msg)
        {
            byte seed = msg.ReadByte();

            byte[] key  = msg.Read(msg.ReadByte());
            string name = msg.ReadString(msg.ReadByte());
            uint   id   = msg.ReadUInt32();

            Encryption.Parameters encryptionParameters = new Encryption.Parameters(key, seed);

            if (ExpectedRedirects.ContainsKey(id) && (ExpectedRedirects[id] != null))
            {
                Redirection r = ExpectedRedirects[id];
                if ((r.Name == name) && r.EncryptionParameters.Matches(encryptionParameters))
                {
                    if (r.SourceServer == Program.LobbyServer || r.SourceServer is LoginServer)
                    {
                        var p = new ServerPacket(0x60);
                        p.WriteByte(0x00);
                        p.WriteUInt32(Notification.Checksum);
                        client.Enqueue(p);

                        var packet = new ServerPacket(0x6F);
                        packet.WriteByte(1);
                        packet.WriteUInt16((ushort)GameServer.MetafileDatabase.Count);
                        foreach (var kvp in GameServer.MetafileDatabase)
                        {
                            packet.WriteString8(kvp.Value.Name);
                            packet.WriteUInt32(kvp.Value.Checksum);
                        }
                        client.Enqueue(packet);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void SendLoginMessage(int type, string msg)
        {
            var p = new ServerPacket(0x02);

            p.WriteByte((byte)type);
            p.WriteString8(msg);
            Enqueue(p);
        }
Ejemplo n.º 6
0
        private void MsgHandler_RequestWebsite(Client client, ClientPacket msg)
        {
            var p1 = new ServerPacket(0x66);

            p1.WriteByte(0x03);
            p1.WriteString8("http://www.wewladh.com");
            client.Enqueue(p1);
        }
Ejemplo n.º 7
0
        public void DisplaySpellBar(Spell s)
        {
            var p = new ServerPacket(0x3A);

            p.WriteUInt16((ushort)s.Icon);
            p.WriteString8(s.Name);
            p.WriteUInt16((ushort)(s.TimeLeft * s.Speed / 1000));
            Enqueue(p);
        }
Ejemplo n.º 8
0
        public void SendWorldMap()
        {
            Player.WorldMap.IsOpen = true;
            var packet = new ServerPacket(0x2E);

            packet.WriteString8(Player.WorldMap.FileName);
            packet.WriteByte((byte)Player.WorldMap.Nodes.Count);
            packet.WriteByte(0x09);
            for (int i = 0; i < Player.WorldMap.Nodes.Count; i++)
            {
                var node = Player.WorldMap.Nodes[i];
                packet.WriteUInt16((ushort)node.X);
                packet.WriteUInt16((ushort)node.Y);
                packet.WriteString8(node.MapName);
                packet.WriteInt32(i);
                packet.WriteUInt16((ushort)node.MapX);
                packet.WriteUInt16((ushort)node.MapY);
            }
            Enqueue(packet);
        }
Ejemplo n.º 9
0
        private void MsgHandler_ClientVersion(Client client, ClientPacket msg)
        {
            var p = new ServerPacket(0x00);

            p.WriteByte(0x00);
            p.WriteUInt32(Program.Checksum);
            p.WriteByte(0x00);
            p.WriteString8("NexonInc.");
            client.Enqueue(p);

            Program.WriteLine("Client connected: {0}", ((IPEndPoint)client.Socket.RemoteEndPoint).Address);
        }
Ejemplo n.º 10
0
        public virtual void Say(string msg, int type)
        {
            foreach (var c in Map.Objects)
            {
                if (c is Player && (WithinRange(c, 12) || type == 1))
                {
                    var player = c as Player;
                    var packet = new ServerPacket(0x0D);
                    packet.WriteByte((byte)type);
                    packet.WriteUInt32(ID);
                    switch (type)
                    {
                    case 0: packet.WriteString8("{0}: {1}", Name, msg); break;

                    case 1: packet.WriteString8("{0}! {1}", Name, msg); break;

                    default: packet.WriteString8(msg); break;
                    }
                    player.Client.Enqueue(packet);
                }
            }
        }
Ejemplo n.º 11
0
        public void SendMapInfo()
        {
            var p = new ServerPacket(0x15);

            p.WriteUInt16((ushort)Player.Map.Number);
            p.WriteByte((byte)(Player.Map.Width % 256));
            p.WriteByte((byte)(Player.Map.Height % 256));
            byte flags = 0;

            if ((Player.Map.Flags & MapFlags.Snow) == MapFlags.Snow)
            {
                flags |= 1;
            }
            if ((Player.Map.Flags & MapFlags.Rain) == MapFlags.Rain)
            {
                flags |= 2;
            }
            if ((Player.Map.Flags & MapFlags.NoMap) == MapFlags.NoMap)
            {
                flags |= 64;
            }
            if ((Player.Map.Flags & MapFlags.Winter) == MapFlags.Winter)
            {
                flags |= 128;
            }
            p.WriteByte(flags);
            p.WriteByte((byte)(Player.Map.Width / 256));
            p.WriteByte((byte)(Player.Map.Height / 256));
            p.WriteByte((byte)(Player.Map.Checksum % 256));
            p.WriteByte((byte)(Player.Map.Checksum / 256));
            p.WriteString8(Player.Map.Name);
            Enqueue(p);

            if (Player.CurrentMusic != Player.Map.Music)
            {
                Player.CurrentMusic = Player.Map.Music;
                SoundEffect(0x8000 + Player.Map.Music);
            }

            Player.WorldMap.IsOpen = false;
        }
Ejemplo n.º 12
0
        public void SendProfile()
        {
            var p = new ServerPacket(0x39);

            p.WriteByte(Player.GameServer.NationDatabase[Player.Nation].Flag);
            p.WriteString8((Player.Guild != null) ? Player.GuildRank.ToString() : string.Empty);

            var masks = new List <byte>();

            for (int i = 0; i < Player.GameServer.TitleDatabase.Count; i++)
            {
                var title = Player.GameServer.TitleDatabase[i];

                var value = i % 8;

                if (value == 0)
                {
                    masks.Add(0);
                }

                var index = masks.Count - 1;

                if (title.Available(Player))
                {
                    switch (value)
                    {
                    case 0: masks[index] += 0x80; break;

                    case 1: masks[index] += 0x40; break;

                    case 2: masks[index] += 0x20; break;

                    case 3: masks[index] += 0x10; break;

                    case 4: masks[index] += 0x08; break;

                    case 5: masks[index] += 0x04; break;

                    case 6: masks[index] += 0x02; break;

                    case 7: masks[index] += 0x01; break;
                    }
                }
            }

            p.WriteByte((byte)masks.Count);
            foreach (var mask in masks)
            {
                p.WriteByte(mask);
            }

            p.WriteByte((byte)Player.Title);
            if (!Player.Group.HasMembers)
            {
                p.WriteString8("그룹 없음");
            }
            else
            {
                StringBuilder sb = new StringBuilder("그룹구성원\n");
                foreach (var player in Player.Group.Members)
                {
                    sb.AppendFormat("{0} {1}\n", (player == Player.Group.Leader) ? "*" : " ", player.Name);
                }
                sb.AppendFormat("총 {0}명", Player.Group.Members.Count);
                p.WriteString8(sb.ToString());
            }
            p.WriteByte(Player.GroupToggle);
            p.WriteByte(0x00); // ??
            p.WriteByte((byte)Player.Class);
            p.WriteByte(0x01); // ??
            p.WriteByte(0x00); // ??
            p.WriteString8(string.Format("{0}{1}{2}",
                                         Player.Master ? "Master " : string.Empty,
                                         (Player.Specialization != Specialization.None) ? Player.Specialization + " " : string.Empty,
                                         Player.Class));
            p.WriteString8((Player.Guild != null) ? Player.Guild.Name : string.Empty);
            p.WriteByte((byte)Player.Legend.Count);
            foreach (var kvp in Player.Legend.OrderBy(l => l.Value.DateUpdated))
            {
                p.WriteByte((byte)kvp.Value.Icon);
                p.WriteByte((byte)kvp.Value.Color);
                p.WriteString8(kvp.Value.Key);
                p.WriteString8(kvp.Value.ToString());
            }
            p.WriteByte(0x00);   // ??
            p.WriteUInt16(Player.DisplayBitmask);
            p.WriteByte(0x02);   // ??
            p.WriteUInt32(0x00); // ??
            p.WriteByte(0x00);   // ??
            Enqueue(p);
        }