Ejemplo n.º 1
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.º 2
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.º 3
0
        private void MsgHandler_RequestNotification(Client client, ClientPacket msg)
        {
            var p1 = new ServerPacket(0x60);

            p1.WriteByte(0x01);
            p1.WriteUInt16((ushort)Notification.RawData.Length);
            p1.Write(Notification.RawData);
            client.Enqueue(p1);
        }
Ejemplo n.º 4
0
        private void MsgHandler_ServerTable(Client client, ClientPacket msg)
        {
            bool mismatch = msg.ReadBoolean();
            int  serverId = msg.ReadByte();

            if (mismatch)
            {
                var p = new ServerPacket(0x56);
                p.WriteUInt16((ushort)Program.RawData.Length);
                p.Write(Program.RawData);
                client.Enqueue(p);
            }
            else
            {
                Redirection r = new Redirection();
                r.DestinationServer    = Program.GameServers[serverId].LoginServer;
                r.EncryptionParameters = client.EncryptionParams;
                r.Name         = String.Format(String.Empty, r.ID);
                r.SourceServer = this;
                client.Redirect(r);
            }
        }
Ejemplo n.º 5
0
        public void SendStatistics(StatUpdateFlags flags)
        {
            if (Player.CanWalkThroughWalls || Player.CanWalkThroughUnits)
            {
                flags |= StatUpdateFlags.GameMasterA;
            }
            else
            {
                flags |= StatUpdateFlags.Swimming;
            }

            var p = new ServerPacket(0x08);

            p.WriteByte((byte)flags);
            if ((flags & StatUpdateFlags.Primary) == StatUpdateFlags.Primary)
            {
                p.Write(new byte[] { 1, 0, 0 });
                p.WriteByte((byte)Player.Level);
                p.WriteByte(0x00);
                p.WriteByte((byte)Player.Ability);
                p.WriteUInt32(Player.MaximumHP);
                p.WriteUInt32(Player.MaximumMP);
                p.WriteUInt16(Player.Str);
                p.WriteUInt16(Player.Int);
                p.WriteUInt16(Player.Wis);
                p.WriteUInt16(Player.Con);
                p.WriteUInt16(Player.Dex);
                p.WriteByte(Player.AvailableStatPoints > 0);
                p.WriteByte((byte)Player.AvailableStatPoints);
                p.WriteUInt16((ushort)Player.MaximumWeight);
                p.WriteUInt16((ushort)Player.CurrentWeight);
                p.WriteUInt32(uint.MinValue);
            }
            if ((flags & StatUpdateFlags.Current) == StatUpdateFlags.Current)
            {
                p.WriteUInt32((uint)Player.CurrentHP);
                p.WriteUInt32((uint)Player.CurrentMP);
            }
            if ((flags & StatUpdateFlags.Experience) == StatUpdateFlags.Experience)
            {
                p.WriteUInt32((uint)Player.Experience);
                p.WriteUInt32((uint)(Player.ToNextLevel - Player.Experience));
                p.WriteUInt32((uint)(Player.ToNextLevel - Player.ToThisLevel));
                p.WriteUInt32((uint)Player.AbilityExp);
                p.WriteUInt32((uint)(Player.ToNextAbility - Player.AbilityExp));
                p.WriteUInt32((uint)(Player.ToNextAbility - Player.ToThisAbility));
                p.WriteUInt32((uint)Player.GamePoints);
                p.WriteUInt32((uint)Player.Gold);
            }
            if ((flags & StatUpdateFlags.Secondary) == StatUpdateFlags.Secondary)
            {
                p.WriteUInt32(uint.MinValue);
                p.WriteUInt16(ushort.MinValue);
                p.WriteByte((byte)Player.OffenseElement);
                p.WriteByte((byte)Player.DefenseElement);
                p.WriteByte((byte)(Player.MagicResistance / 10));
                p.WriteByte(byte.MinValue);
                p.WriteSByte(Player.ArmorClass);
                p.WriteSByte(Player.Dmg);
                p.WriteSByte(Player.Hit);
            }
            Enqueue(p);
        }