Beispiel #1
0
        public override void SendPacket(Packet pPacket)
        {
            pPacket.SwitchOver();
            exporter.AddPacket(pPacket, true);
            pPacket.SwitchOver();

            base.SendPacket(pPacket);
        }
Beispiel #2
0
            public DumpPacket(Packet pPacket, bool pFromServer)
            {
                pPacket.Reset();
                Outboud = !pFromServer;
                Opcode = pPacket.ReadUShort();

                Data = new byte[pPacket.Length - 2];
                Buffer.BlockCopy(pPacket.ToArray(), 2, Data, 0, Data.Length); // byte + short (header)
                ArrivalTime = DateTime.Now;
                pPacket.Reset();
            }
Beispiel #3
0
        public virtual void Write(Packet pPacket)
        {
            byte type = 2;
            if (ItemID / 1000000 == 1) type = 1;
            else if (ItemID / 10000 == 500) type = 3; // Pet

            pPacket.WriteByte(type);
            pPacket.WriteInt(ItemID);

            pPacket.WriteBool(false); // No cash id

            pPacket.WriteLong(this.Expires); // Expire date

            pPacket.WriteInt(this.BagID); // Bag ID

        }
Beispiel #4
0
        public static void SendTestItem(Session pSession, int pItemID, short pSlot = 1)
        {
            Packet packet = new Packet(0x0025);
            packet.WriteBool(true); // Unstuck

            packet.WriteByte(1); // Items
            packet.WriteByte(0); // Mode

            {
                packet.WriteByte(0); // New item
                packet.WriteByte((byte)(pItemID / 1000000)); // Inventory
                packet.WriteShort(pSlot);

                byte type = 2;
                if (pItemID / 1000000 == 1) type = 1;
                else if (pItemID / 10000 == 500) type = 3; // Pet

                if (type == 1)
                {
                    ItemEquip equip = new ItemEquip(pItemID); // Wizet Invincible Hat 2
                    equip.Write(packet);
                }
                else if (type == 2)
                {
                    ItemRechargable regitem = new ItemRechargable(pItemID);
                    regitem.Write(packet);
                }
                else if (type == 2)
                {
                    ItemPet pet = new ItemPet(pItemID);
                    pet.Write(packet);
                }
            }


            pSession.SendPacket(packet);
        }
Beispiel #5
0
 public virtual void OnHandshakeInbound(Packet pPacket)
 {
     Console.WriteLine(TypeName + " No Handshake Handler.");
 }
Beispiel #6
0
 public virtual void OnPacketInbound(Packet pPacket)
 {
     Console.WriteLine(TypeName + " No Handler for 0x{0:X4}", pPacket.ReadUShort());
 }
Beispiel #7
0
        public void SendHandshake(ushort pVersion, string pPatchLocation, byte pLocale)
        {
            _encryptIV = new byte[4];
            rnd.NextBytes(_encryptIV);
            _decryptIV = new byte[4];
            rnd.NextBytes(_decryptIV);

            Packet packet = new Packet();
            packet.WriteUShort(pVersion);
            packet.WriteString(pPatchLocation);
            packet.WriteBytes(_decryptIV);
            packet.WriteBytes(_encryptIV);
            packet.WriteByte(pLocale);
            SendPacket(packet);
            _mapleVersion = pVersion;
            _maplePatchLocation = pPatchLocation;
            _mapleLocale = pLocale;


            _rijndaelAES.Key = GMSKeys.GetKeyForVersion(_mapleVersion);
            _rijndaelAES.Mode = CipherMode.ECB;
            _rijndaelAES.Padding = PaddingMode.PKCS7;
            _transformer = _rijndaelAES.CreateEncryptor();
        }
Beispiel #8
0
 public string PrintPacket(Packet pPacket, string pWhat, bool ret = false) { return PrintPacket(pWhat, pPacket.ToArray(), false); }
Beispiel #9
0
 private void WriteFlaggedValue(Packet pPacket, uint pFlag, ushort pValue, ref uint pOutputFlag)
 {
     if (pValue == 0) return;
     pPacket.WriteUShort(pValue);
     pOutputFlag |= pFlag;
 }
Beispiel #10
0
 public void AddPacket(Packet pPacket, bool pFromServer)
 {
     _packets.Add(new DumpPacket(pPacket, pFromServer));
 }
Beispiel #11
0
        public override void Write(Packet pPacket)
        {
            base.Write(pPacket);


            pPacket.WriteString(this.Petname, 13);
            pPacket.WriteByte(this.Level);
            pPacket.WriteShort(this.Closeness);
            pPacket.WriteByte(this.Fullness);

            pPacket.WriteLong(this.Expires);

            throw new NotImplementedException();
            //  pPacket.Skip(2 + 2 + 4 + 2 + 1 + 4 + 4 + 2);

            // Last 2:
            // - int: -1
            // - short: 100
            // V.132: + 2
        }
Beispiel #12
0
        public override void Write(Packet pPacket)
        {
            base.Write(pPacket);

            pPacket.WriteShort(this.Amount);
            pPacket.WriteString(this.CraftName);
            pPacket.WriteShort(this.Flags);

            int itemtype = ItemID / 10000;
            if (itemtype == 233 || itemtype == 207 || itemtype == 287 || itemtype == 288 || itemtype == 289) // Stars, Bullets & Familiars
                pPacket.WriteLong(this.UniqueID);

        }
Beispiel #13
0
 private void WriteFlaggedValue(Packet pPacket, uint pFlag, long pValue, ref uint pOutputFlag)
 {
     if (pValue == 0) return;
     pPacket.WriteLong(pValue);
     pOutputFlag |= pFlag;
 }
Beispiel #14
0
        public static void SendTestItem(Session pSession, ItemBase pItem, short pSlot = 1)
        {
            Packet packet = new Packet(0x0025);
            packet.WriteBool(true); // Unstuck

            packet.WriteByte(1); // Items
            packet.WriteByte(0); // Mode

            {
                packet.WriteByte(0); // New item
                packet.WriteByte((byte)(pItem.ItemID / 1000000)); // Inventory
                packet.WriteShort(pSlot); // Slot 1

                pItem.Write(packet);
            }


            pSession.SendPacket(packet);
        }
Beispiel #15
0
        /// <summary>
        /// Used as IAsyncResult parser for ContinueReading().
        /// </summary>
        /// <param name="pIAR">The result AsyncCallback makes</param>
        private void EndReading(IAsyncResult pIAR)
        {
            int amountReceived = 0;
            try
            {
                amountReceived = _socket.EndReceive(pIAR);
            }
            catch (Exception ex)
            {
                Console.WriteLine(TypeName + " : " + ex.ToString());
                amountReceived = 0;
            }
            if (amountReceived == 0)
            {
                // We got a disWvsBeta.Common.Sessions here!
                OnDisconnectINTERNAL();
                return;
            }

            // Add amount of bytes received to _bufferpos so we know if we got everything.
            _bufferpos += amountReceived;

            try
            {

                // Check if we got all data. There is _no_ way we would have received more bytes than needed. Period.
                if (_bufferpos == _bufferlen)
                {
                    // It seems we have all data we need
                    // Now check if we got a header
                    if (_header)
                    {
                        if (!_encryption && _receivingFromServer)
                        {
                            // Unencrypted packets have a short header with plain length.
                            ushort length = (ushort)(_buffer[0] | _buffer[1] << 8);
                            StartReading(length);
                        }
                        else
                        {
                            int length = GetHeaderLength(_buffer);
                            StartReading(length);
                        }
                    }
                    else
                    {
                        Packet packet;
                        if (_encryption)
                        {
                            _buffer = Decrypt(_buffer);
                            packet = new Packet(_buffer);

                            DoAction((date) =>
                            {
                                try
                                {
                                    OnPacketInbound(packet);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Handling Packet Error: {0}", ex.ToString());
                                }
                            });
                        }
                        else
                        {
                            _encryption = true; // First packet received or sent is unencrypted. All others are.
                            packet = new Packet(_buffer);

                            _mapleVersion = packet.ReadUShort();
                            _maplePatchLocation = _maplePatchLocation = packet.ReadString();
                            _encryptIV = packet.ReadBytes(4);
                            _decryptIV = packet.ReadBytes(4);
                            _mapleLocale = packet.ReadByte();
                            Console.WriteLine(TypeName + " MapleVersion: {0}; Patch Location: {1}; Locale: {2}", _mapleVersion, _maplePatchLocation, _mapleLocale);


                            _rijndaelAES.Key = GMSKeys.GetKeyForVersion(_mapleVersion);
                            _rijndaelAES.Mode = CipherMode.ECB;
                            _rijndaelAES.Padding = PaddingMode.PKCS7;
                            _transformer = _rijndaelAES.CreateEncryptor();

                            packet.Reset();
                            DoAction((date) =>
                            {
                                try
                                {
                                    OnHandshakeInbound(packet);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Handling Packet Error: {0}", ex.ToString());
                                }
                            });
                        }

                        StartReading(4, true);
                    }
                }
                else
                {
                    ContinueReading();
                }

            }
            catch (SocketException socketException)
            {
                Console.WriteLine(TypeName + " Socket Exception while receiving data: {0}", socketException.Message);
                OnDisconnectINTERNAL();
            }
            catch (Exception ex)
            {
                Console.WriteLine(TypeName + " [ERROR] EndReading(): {0}", ex.ToString());
                OnDisconnectINTERNAL();
            }
        }
Beispiel #16
0
        public static void EnterMapPacket(Session pSession, bool pConnecting, int pToMapID)
        {
            Packet packet = new Packet(Program.CHANGE_MAP_HEADER);
            {
                // Option list
                packet.WriteShort(2); // Amount

                packet.WriteInt(1);
                packet.WriteInt(0);

                packet.WriteInt(2);
                packet.WriteInt(0);
            }
            packet.WriteInt(12); // Channel

            packet.WriteByte(0);
            packet.WriteInt(0);

            packet.WriteByte(1); // Portals

            packet.WriteInt(0); // ...


            packet.WriteBool(pConnecting); // Is Connecting

            if (true)
            {
                packet.WriteShort(1); // Lines
                packet.WriteString("Test Server"); // Title
                packet.WriteString("This is a test server!");
            }
            else
            {
                packet.WriteShort(0);
            }

            if (pConnecting)
            {
                // Random Numbers for damage calculation
                packet.WriteUInt(4078638766);
                packet.WriteUInt(1285450110);
                packet.WriteUInt(2894412159);

                {
                    // Char Data
                    ulong flag = 0xFFDFFFFFFFFFFFFF;

                    packet.WriteULong(flag);
                    packet.WriteByte(0);


                    packet.WriteInt(0);
                    packet.WriteInt(0);
                    packet.WriteInt(0);

                    packet.WriteByte(0); // Loop1

                    packet.WriteInt(0); // Loop 2

                    packet.WriteByte(0);

                    packet.WriteBool(false);

                    {
                        // Stats

                        packet.WriteInt(1337); // ID
                        packet.WriteString("TestBoooii", 13);

                        packet.WriteByte(0);
                        packet.WriteByte(3);
                        packet.WriteInt(20100);
                        packet.WriteInt(33830);

                        // Pets
                        packet.WriteLong(0);
                        packet.WriteLong(0);
                        packet.WriteLong(0);

                        packet.WriteByte(250); // Level

                        short job = 910; // 910 = SGM
                        packet.WriteShort(job);

                        packet.WriteShort(1000); // STR
                        packet.WriteShort(2000); // DEX
                        packet.WriteShort(3000); // INT
                        packet.WriteShort(4000); // LUK

                        packet.WriteInt(500000); // HP
                        packet.WriteInt(500000); // Max HP
                        packet.WriteInt(500000); // MP
                        packet.WriteInt(500000); // Max MP

                        packet.WriteShort(0); // AP
                        if (IsExtendedSPJob(job)) packet.WriteByte(0);
                        else packet.WriteShort(0);

                        packet.WriteLong(123456789); // EXP
                        packet.WriteInt(0xBADF00D); // Fame

                        packet.WriteInt(10000); // Gacha EXP
                        packet.WriteInt(0); // V.141 unk

                        packet.WriteInt(pToMapID); // GM map
                        packet.WriteByte(0); // Map pos

                        packet.WriteInt(0); // Unk?

                        packet.WriteShort(0); // Job sub ID?

                        if (job / 100 == 31 || job / 100 == 36 || job == 3001 || job == 3002)
                        {
                            packet.WriteInt(1012278);
                        }

                        packet.WriteByte(0); // Fatigue

                        packet.WriteInt(int.Parse(DateTime.Now.ToString("yyyyMMddHH")));

                        // Traits
                        for (int i = 0; i < 6; i++)
                            packet.WriteInt(100 * i);

                        // Traits today
                        for (int i = 0; i < 6; i++)
                            packet.WriteUShort((ushort)(50 * i));

                        // 9 bytes leftover
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteByte(0);


                        packet.WriteInt(0);
                        packet.WriteByte(0);
                        packet.WriteInt(0);
                        packet.WriteByte(0);
                        packet.WriteByte(0);
                        packet.WriteInt(0);
                        packet.WriteByte(0);

                        packet.WriteInt(0);
                        packet.WriteInt(0);

                        packet.WriteInt(0);

                        packet.WriteByte(0);

                        // Parttime jobs
                        for (int i = 1; i <= 9; i++)
                        {

                            packet.WriteInt(0);
                            packet.WriteByte(0);
                            packet.WriteInt(0);
                        }


                        packet.WriteInt(0); // 'reverse' time!
                        packet.WriteInt(0);
                    }


                    packet.WriteByte(100); // Buddylist size

                    packet.WriteBool(false); // Blessings
                    packet.WriteBool(false);
                    packet.WriteBool(false);

                    packet.WriteLong(133713371337); // Mesos

                    packet.WriteInt(0); // Some loop
                    packet.WriteInt(0); // Magic Potions loop

                    {
                        // Inventories

                        for (int i = 0; i < 5; i++)
                            packet.WriteByte(8 * 10); // inventory slots

                        packet.WriteLong(94354848000000000); // Some say it's a date for a quest. I don't believe them

                        // Equips
                        for (int i = 0; i < 3 + 9 + 1; i++)
                        {
                            packet.WriteShort(0); // No items!
                        }

                        // Regular inventories
                        for (int i = 0; i < 4; i++)
                        {
                            packet.WriteByte(0); // No items!
                        }

                        // Bags
                        for (int i = 3; i <= 4; i++)
                        {
                            packet.WriteInt(0);
                        }
                    }

                    packet.WriteInt(0); // Loopies
                    packet.WriteInt(0);

                    // while loop here
                    packet.WriteByte(0); // Stop while loop.

                    {
                        // Skills

                        packet.WriteBool(true);
                        if (true)
                        {
                            packet.WriteShort(0); // No skills
                            packet.WriteShort(0); // No link skills
                        }
                        else
                        {
                            // I aint going to program this..
                        }

                        packet.WriteShort(0); // No cooldowns either
                    }

                    {
                        // Quests
                        bool wut = false;
                        packet.WriteBool(wut);
                        packet.WriteShort(0);

                        if (!wut)
                            packet.WriteShort(0);

                        packet.WriteShort(0);

                        wut = false;
                        packet.WriteBool(wut);
                        packet.WriteShort(0);

                        if (!wut)
                            packet.WriteShort(0);
                    }

                    packet.WriteShort(0); // Match records

                    {
                        // Bunch o rings

                        packet.WriteShort(0); // Couple
                        packet.WriteShort(0); // Friend
                        packet.WriteShort(0); // Marriage
                    }

                    // Tele rocks
                    for (int i = 0; i < 5 + 10 + 13 + 13; i++)
                        packet.WriteInt(999999999);


                    {
                        // Monsterbook

                        packet.WriteInt(0); // Chosen card
                        packet.WriteBool(false); // Method to use; false = old loop
                        packet.WriteShort(0);
                    }

                    packet.WriteInt(-1); // ?

                    packet.WriteShort(0);

                    // Newyear cards
                    packet.WriteShort(0);

                    // PQ data
                    packet.WriteShort(0);

                    // Wildhunter info... no
                    if (false)
                    {
                        packet.WriteByte(1);
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                    }

                    // Finished PQs
                    packet.WriteShort(0);

                    // Some event stuff
                    packet.WriteShort(0);

                    // Stolen skills
                    for (int i = 13; i > 0; i--)
                        packet.WriteInt(0);

                    // Chosen skills?
                    for (int i = 4; i > 0; i--)
                        packet.WriteInt(0);

                    // Inner stats
                    packet.WriteShort(0);

                    {
                        // Unknown stuff
                        packet.WriteInt(0);

                        packet.WriteByte(0);
                    }


                    // Honour info
                    packet.WriteInt(1337); // Level
                    packet.WriteInt(0); // EXP

                    {
                        // More unknown stuffs :(
                        packet.WriteByte(1); // Use first loop
                        packet.WriteShort(0); // End loop
                    }

                    packet.WriteBool(false); // Item decode if true

                    {
                        packet.WriteInt(1680023);
                        packet.WriteInt(1680024);
                        packet.WriteInt(1680025);
                        packet.WriteByte(1);
                    }

                    {
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteLong(94354848000000000);
                    }

                    {
                        // Evolution Cores
                        packet.WriteShort(0);
                        packet.WriteShort(0);
                    }

                    packet.WriteByte(0);

                    {
                        // Farm info
                        packet.WriteString("Creating...");
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);

                        packet.WriteByte(0);

                        packet.WriteInt(0);
                        packet.WriteInt(0);
                        packet.WriteInt(0);

                        packet.WriteInt(0);
                        packet.WriteInt(0);
                    }

                    packet.WriteBool(false); // More item decode thingies

                    {
                        packet.WriteInt(0);
                        packet.WriteLong(94354848000000000);
                        packet.WriteInt(0);
                    }

                    {
                        // Decodes 84 bytes

                        packet.WriteInt(1257960);
                        // 4
                        for (int i = 0; i < 64; i += 8)
                            packet.WriteLong(0);
                        // 68
                        packet.WriteShort(0);
                        packet.WriteByte(0);
                        // 71

                        // Ohkay
                        packet.WriteLong(DateTime.Now.ToFileTime());
                        // 79

                        packet.WriteInt(0);
                        packet.WriteByte(1);
                        // 84
                    }

                    packet.WriteByte(0);

                    // loop...
                    packet.WriteShort(0);

                    {
                        packet.WriteInt(9995561);
                        packet.WriteInt(2027067);
                        packet.WriteInt(4);
                        packet.WriteInt(0);

                        for (int i = 0; i < 4; i++)
                        {
                            packet.WriteInt(9410165 + i);
                            packet.WriteInt(i * 1000);
                        }
                    }

                    {
                        // Bulk info
                        packet.WriteInt(0);
                    }
                }
            }
            else
            {
                packet.WriteByte(0);

                packet.WriteInt(pToMapID); // Mapid
                packet.WriteByte(0); // Mapppos

                packet.WriteInt(13371337); // HP

                packet.WriteBool(false);
            }


            packet.WriteLong(DateTime.Now.ToFileTime());
            packet.WriteInt(100);
            packet.WriteByte(0);
            packet.WriteByte(0);
            packet.WriteByte(1);

            pSession.SendPacket(packet);
        }
Beispiel #17
0
 public virtual void SendPacket(Packet pPacket)
 {
     SendData(pPacket.ToArray());
 }
Beispiel #18
0
        public override void OnPacketInbound(Packet pPacket)
        {
            exporter.AddPacket(pPacket, false);

            ushort header = pPacket.ReadUShort();
            Console.WriteLine("Packet: {0}", pPacket.ToString());
            if (header == 0x0038) //(header == 0x0043)
            {
                // Version? > lets get rollin
                ServerPackets.EnterMapPacket(this, true, 180000000);

                short slot = 1;

                foreach (var kvp in Program.ITEMS)
                    ServerPackets.SendTestItem(this, kvp.Value, kvp.Key);

                /*

                ServerPackets.SendTestItem(this, 1003142, slot++);
                ServerPackets.SendTestItem(this, 1102275, slot++);

                ItemEquip equip = new ItemEquip(1222009)
                {
                    BattleModeDamage = 20,
                    BossDamageRate = 30,
                    Durability = 500000,
                    IgnoreDamageRate = 50,
                };
                ServerPackets.SendTestItem(this, equip, slot++);

                equip = new ItemEquip(1003142)
                {
                    AllStatsPercentage = 11,
                    TotalDamagePercentage = 22,
                    IncreasesSkills = 33
                };

                ushort statusflag = 0;
                statusflag |= 0x0020;
                //statusflag |= 0x2000;

                equip.StatusFlags = statusflag;

                ServerPackets.SendTestItem(this, equip, slot++);


                equip = new ItemEquip(1003142)
                {
                    Durability = 100,
                };
                ServerPackets.SendTestItem(this, equip, slot++);



                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0001 }, slot++); // Potential?
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0002 }, slot++); // Potential?
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0004 }, slot++); // Potential?
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0008 }, slot++); // Potential?
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0010 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0020 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0040 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113015) { StatusFlags = 0x0080 }, slot++);

                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x0001 }, slot++); 
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x0002 }, slot++); 
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x0004 }, slot++); 
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x0008 }, slot++); 
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x001F }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x002F }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x004F }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113016) { SocketState = 0x008F }, slot++);

                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x0100 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x0200 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x0400 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x0800 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x1000 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x2000 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x4000 }, slot++);
                ServerPackets.SendTestItem(this, new ItemEquip(1113017) { SocketState = 0x8000 }, slot++);

                ServerPackets.SendTestItem(this, new ItemEquip(1113017)
                {
                    StatusFlags = 0x0714,
                    Potential1 = 40356,
                    Potential2 = 30041,
                    Potential3 = 30044,
                    Potential4 = 12011,
                    Potential5 = 2014,
                    Potential6 = 2014,
                    SocketState = 0x00FF,
                    Nebulite2 = 1001,
                    Nebulite1 = 2001,
                    Nebulite3 = 3400,

                }, slot++);
                */

            }
            else if (header == 0x0030)
            {
                int request = pPacket.ReadInt();
                int response;

                response = ((request >> 5) << 5) + (((((request & 0x1F) >> 3) ^ 2) << 3) + (7 - (request & 7)));
                response |= ((request >> 7) << 7);
                response -= 2;

                Packet packet = new Packet(0x0015);
                packet.WriteInt(response);
                this.SendPacket(packet);
            }
            else if (header == 0x040)
            {
                Packet packet = new Packet(0x0000);
                packet.WriteInt(0);
                packet.WriteShort(0);
                
                packet.WriteInt(12222222); // User ID
                packet.WriteByte(0);
                packet.WriteByte(0);
                packet.WriteUShort(0xFFFF); // admin flags
                packet.WriteInt(0);
                packet.WriteByte(0x95);
                packet.WriteString("TestUser"); // Username
                packet.WriteByte(0);
                packet.WriteByte(0);
                packet.WriteLong(0);
                packet.WriteLong(128664365579370000); // create date

                packet.WriteInt(78);

                packet.WriteBool(false); // Else, 18 bytes
                packet.WriteBool(true); // Send 0x22 back
                packet.WriteByte(0);

                packet.WriteLong(0); // CC key

                this.SendPacket(packet);
            }
            else if (header == 0x0022)
            {
                Packet packet = new Packet(0x0009);
                byte worldid = 41;
                string worldname = "Ultimate";
                byte channels = 10;

                packet.WriteByte(worldid);
                packet.WriteString(worldname);
                packet.WriteByte(1);
                packet.WriteString("");
                packet.WriteUShort(100);
                packet.WriteUShort(100);

                packet.WriteByte(0);

                packet.WriteByte(channels); // Channels
                for (byte i = 0; i < channels; i++)
                {
                    packet.WriteString(string.Format("{0}-{1}", worldname, i + 1));
                    packet.WriteInt(1000);
                    packet.WriteByte(worldid);
                    packet.WriteByte(i);
                    packet.WriteByte(0);
                }

                packet.WriteShort(0); // Tooltip thingies

                packet.WriteInt(0);

                this.SendPacket(packet);

                packet = new Packet(0x0009);
                packet.WriteByte(0xFF);
                packet.WriteByte(0); // ? Restriction message?
                this.SendPacket(packet);

            }
            else if (header == 0x001D)
            {
                Packet packet = new Packet(0x0004);
                packet.WriteByte(0); // Server status
                packet.WriteByte(0);
                this.SendPacket(packet);
            }
            else
            {
                Console.WriteLine("Unknown");
            }
        }
Beispiel #19
0
        public override void Write(Packet pPacket)
        {
            base.Write(pPacket);

            if (this.SocketState != 0)
            {
                this.SocketState |= 0x0001;
            }

            {
                // flags 1
                uint flag = 0;
                int tmp = pPacket.Position;
                pPacket.WriteInt(0);

                // this\.([a-zA-Z]+) = FlaggedValue\(pConnection, this\.ItemID, flag, 0x([0-9]+), pPacket, this\.([a-zA-Z]+)\);
                // WriteFlaggedValue\(pPacket, 0x\2, this.\1, ref flag\);

                WriteFlaggedValue(pPacket, 0x00000001, this.Slots, ref flag);
                WriteFlaggedValue(pPacket, 0x00000002, this.Scrolls, ref flag);
                WriteFlaggedValue(pPacket, 0x00000004, this.Str, ref flag);
                WriteFlaggedValue(pPacket, 0x00000008, this.Dex, ref flag);
                WriteFlaggedValue(pPacket, 0x00000010, this.Int, ref flag);
                WriteFlaggedValue(pPacket, 0x00000020, this.Luk, ref flag);
                WriteFlaggedValue(pPacket, 0x00000040, this.HP, ref flag);
                WriteFlaggedValue(pPacket, 0x00000080, this.MP, ref flag);
                WriteFlaggedValue(pPacket, 0x00000100, this.Watk, ref flag);
                WriteFlaggedValue(pPacket, 0x00000200, this.Matk, ref flag);
                WriteFlaggedValue(pPacket, 0x00000400, this.Wdef, ref flag);
                WriteFlaggedValue(pPacket, 0x00000800, this.Mdef, ref flag);
                WriteFlaggedValue(pPacket, 0x00001000, this.Acc, ref flag);
                WriteFlaggedValue(pPacket, 0x00002000, this.Avo, ref flag);
                WriteFlaggedValue(pPacket, 0x00004000, this.Hands, ref flag);
                WriteFlaggedValue(pPacket, 0x00008000, this.Speed, ref flag);
                WriteFlaggedValue(pPacket, 0x00010000, this.Jump, ref flag);
                WriteFlaggedValue(pPacket, 0x00020000, this.Flags, ref flag);

                WriteFlaggedValue(pPacket, 0x00040000, this.IncreasesSkills, ref flag);

                WriteFlaggedValue(pPacket, 0x00080000, this.ItemLevel, ref flag);
                WriteFlaggedValue(pPacket, 0x00100000, this.ItemEXP, ref flag);


                WriteFlaggedValue(pPacket, 0x00200000, this.Durability, ref flag);
                WriteFlaggedValue(pPacket, 0x00400000, this.ViciousHammer, ref flag);

                WriteFlaggedValue(pPacket, 0x00800000, this.BattleModeDamage, ref flag);

                // FlaggedValue\(pConnection, this\.ItemID, flag, 0x([0-9]+), pPacket, \(([a-zA-Z]+)\)(0), true\);
                // WriteFlaggedValue\(pPacket, 0x\1, \(\2\)\3, ref flag\);

                WriteFlaggedValue(pPacket, 0x01000000, this.EquipmentLevelReduction, ref flag); // Item level changer?
                WriteFlaggedValue(pPacket, 0x02000000, (short)0, ref flag); // Enhancement buff?
                WriteFlaggedValue(pPacket, 0x04000000, this.SecondDurability, ref flag); // Second durability
                WriteFlaggedValue(pPacket, 0x08000000, (byte)0, ref flag); // Required level changer?!
                WriteFlaggedValue(pPacket, 0x10000000, (byte)0, ref flag); // Yggdrasil Wisdom? | If higher than 1, 'Success'
                WriteFlaggedValue(pPacket, 0x20000000, (byte)0, ref flag); // Final Strike? | If higher than 1, 'Success'

                WriteFlaggedValue(pPacket, 0x40000000, this.BossDamageRate, ref flag);
                WriteFlaggedValue(pPacket, 0x80000000, this.IgnoreDamageRate, ref flag);

                pPacket.SetUInt(tmp, flag);
            }

            {
                // flags 2
                uint flag = 0;
                int tmp = pPacket.Position;
                pPacket.WriteInt(0);

                WriteFlaggedValue(pPacket, 0x01, this.TotalDamagePercentage, ref flag);
                WriteFlaggedValue(pPacket, 0x02, this.AllStatsPercentage, ref flag);
                WriteFlaggedValue(pPacket, 0x04, this.MaxScissors, ref flag);
                WriteFlaggedValue(pPacket, 0x08, (long)0, ref flag);
                WriteFlaggedValue(pPacket, 0x10, (int)0, ref flag);

                pPacket.SetUInt(tmp, flag);
            }

            pPacket.WriteString(this.Name);
            pPacket.WriteUShort(this.StatusFlags);


            pPacket.WriteUShort(this.Potential1);
            pPacket.WriteUShort(this.Potential2);
            pPacket.WriteUShort(this.Potential3);

            pPacket.WriteUShort(this.Potential4);
            pPacket.WriteUShort(this.Potential5);
            pPacket.WriteUShort(this.Potential6);

            pPacket.WriteUShort(this.DisplayID);

            pPacket.WriteUShort(this.SocketState);
            pPacket.WriteShort(this.Nebulite1);
            pPacket.WriteShort(this.Nebulite2);
            pPacket.WriteShort(this.Nebulite3);

            // If cash id
            pPacket.WriteLong(this.UniqueID);

            pPacket.WriteLong(0);
            pPacket.WriteInt(-1);

        }