public void Decode(MaplePacket pPacket)
        {
            InventorySlots = new byte[INVENTORIES];
            for (int i = 0; i < INVENTORIES; i++)
            {
                InventorySlots[i] = pPacket.ReadByte();
            }

            pPacket.ReadLong(); // 94354848000000000 | 1-1-1900



            EquipmentItems = new Dictionary <short, ItemEquip> [EQUIP_INVENTORIES];

            for (byte i = 0; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary <short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0)
                    {
                        break;
                    }

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }

            InventoryItems = new Dictionary <byte, ItemBase> [NORMAL_INVENTORIES];

            for (byte i = 0; i < NORMAL_INVENTORIES; i++)
            {
                InventoryItems[i] = new Dictionary <byte, ItemBase>();

                while (true)
                {
                    byte slot = pPacket.ReadByte();
                    if (slot == 0)
                    {
                        break;
                    }

                    ItemBase item = ItemBase.DecodeItemData(pPacket);

                    InventoryItems[i].Add(slot, item);
                }
            }
        }
Ejemplo n.º 2
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            InventorySlots = new byte[INVENTORIES];
            for (int i = 0; i < INVENTORIES; i++)
            {
                InventorySlots[i] = pPacket.ReadByte();
            }

            pPacket.ReadLong(); // 94354848000000000 | 1-1-1900



            EquipmentItems = new Dictionary <short, ItemEquip> [EQUIP_INVENTORIES];
#if LOCALE_EMS
            for (byte i = 0; i < 3; i++)
            {
                EquipmentItems[i] = new Dictionary <short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0)
                    {
                        break;
                    }
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }

            pPacket.ReadBool(); // EMS only -.-

            for (byte i = 3; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary <short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0)
                    {
                        break;
                    }
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }
#else
            for (byte i = 0; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary <short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0)
                    {
                        break;
                    }
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }
#endif

            InventoryItems = new Dictionary <byte, ItemBase> [NORMAL_INVENTORIES];
            BagItems       = new Dictionary <int, BagItem>();

            for (byte i = 0; i < NORMAL_INVENTORIES; i++)
            {
                InventoryItems[i] = new Dictionary <byte, ItemBase>();

                while (true)
                {
                    byte slot = pPacket.ReadByte();
                    if (slot == 0)
                    {
                        break;
                    }

                    ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);
                    InventoryItems[i].Add(slot, item);

                    if (item.BagID != -1)
                    {
                        // Update BagID... O.o
                        item.BagID = GameHelper.GetBagID(item.BagID, i);

                        BagItem bi = new BagItem(item);
                        BagItems.Add(item.BagID, bi);
                    }
                }
            }

            // Bagzzz
            for (int inv = 3; inv <= 4; inv++)
            {
                var bags = pPacket.ReadInt();
                for (int i = 0; i < bags; i++)
                {
                    int bagid = pPacket.ReadInt();

                    int bagitemid = pPacket.ReadInt();

                    BagItem bi = BagItems[GameHelper.GetBagID(bagid, inv - 2)]; // No addition to inv...!

                    while (true)
                    {
                        int slotid = pPacket.ReadInt();
                        if (slotid == -1)
                        {
                            break;
                        }

                        ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);
                        bi.Items.Add((byte)slotid, item);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            pPacket.Skip(8); // Flag

#if LOCALE_GMS
            pPacket.Skip(1);
#endif

            {
                // Added GMS V.132
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

#if LOCALE_EMS
            pPacket.Skip(1);
#endif

            int tmp = pPacket.ReadByte();
            pPacket.Skip(tmp * 4);

            tmp = pPacket.ReadInt();
            pPacket.Skip(tmp * (4 + 8));


#if LOCALE_GMS
            pPacket.Skip(1);
#endif

            if (pPacket.ReadBool())
            {
                tmp = pPacket.ReadInt();
                pPacket.Skip(tmp * 8);
                tmp = pPacket.ReadInt();
                pPacket.Skip(tmp * 8);
            }

            Stats = new GW_CharacterStat();
            Stats.Decode(pPacket);

            this.BuddylistSize = pPacket.ReadByte();
#if LOCALE_EMS
            pPacket.ReadByte();
#endif

            if (pPacket.ReadBool())
            {
                BlessingOfTheFairy = pPacket.ReadString();
            }
            else
            {
                BlessingOfTheFairy = null;
            }
            if (pPacket.ReadBool())
            {
                BlessingOfEmpress = pPacket.ReadString();
            }
            else
            {
                BlessingOfEmpress = null;
            }
            if (pPacket.ReadBool())
            {
                UltimateExplorer = pPacket.ReadString();
            }
            else
            {
                UltimateExplorer = null;
            }

            Stats.DecodeMesos(pPacket); // .-.

#if LOCALE_EMS
            pPacket.ReadByte(); // Bool check
            pPacket.ReadInt();
#endif


            // Unknown stuff here

            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
            }

#if LOCALE_GMS
            // Magical potion pots!!!
            for (int i = pPacket.ReadInt(); i > 0; i--) // V.126
            {
                pPacket.ReadInt();                      // Potion pot ID
                pPacket.ReadInt();                      // Max value
                pPacket.ReadInt();                      // HP
                pPacket.ReadInt();                      // ??? (Not max value of MP)
                pPacket.ReadInt();                      // MP

                pPacket.ReadLong();                     // Start date O.o?
                pPacket.ReadLong();                     // End date O.o?
            }
#endif


#if LOCALE_GMS
            // V.142 - RED stuff?

            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

            {
                pPacket.ReadInt();
                for (int i = 3; i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                }
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
            }

            if (pPacket.ReadBool())
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
                pPacket.ReadLong();
                pPacket.ReadLong();
            }

            for (int j = 0; j < 2; j++) // called 2 times under each other!
            {
                for (int i = pPacket.ReadByte(); i > 0; i--)
                {
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadString();
                }
            }
#endif

#if LOCALE_EMS
            // REMOVED GMS V.141?!
            for (int i = pPacket.ReadInt(); i > 0; i--) // V.137
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

            pPacket.ReadInt();
            for (int i = 6; i > 0; i--)
            {
                pPacket.ReadInt();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadString();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadString();
            }
#endif

            Inventory = new CharacterInventory();
            Inventory.Decode(pConnection, pPacket);

            //UnknownIntegerListNumber3 = new Dictionary<int, long>();
            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadLong();
                //UnknownIntegerListNumber3.Add(pPacket.ReadInt(), pPacket.ReadLong());
            }

            //UnknownIntegerListNumber4 = new Dictionary<long, long>();
            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadLong();
                pPacket.ReadLong();
                //UnknownIntegerListNumber4.Add(pPacket.ReadLong(), pPacket.ReadLong());
            }


            while (true)
            {
                byte val = pPacket.ReadByte();
                if (val == 0)
                {
                    break;
                }

                {
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                }
            }


            Skills = new CharacterSkills();
            Skills.Decode(pConnection, pPacket);

            Quests = new CharacterQuests();
            Quests.Decode(pConnection, pPacket);


            // Match
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }


            {
                Rings       = new List <Ring>();
                MarriedWith = null;

                // Couple
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Rings.Add(new Ring(Ring.Type.Couple, pPacket));
                }

                // Friend
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Rings.Add(new Ring(Ring.Type.Friend, pPacket));
                }

                // Marriage
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Ring ring = new Ring(Ring.Type.Marriage, pPacket, Stats.Name);
                    Rings.Add(ring);

                    MarriedWith = ring.FriendName;
                }
            }


            Inventory.DecodeTeleportRocks(pPacket);

#if LOCALE_GMS
            Monsterbook = new CharacterMonsterBook();
            Monsterbook.Decode(pPacket);

            pPacket.ReadInt(); // -1?

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadShort();
            }

            {
                // Newyear cards... meh
                // WHAT MEH, SOMEONE HAS THIS FFS D:!!!

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadInt();    // Card ID?
                    pPacket.ReadInt();    // Sender ID
                    pPacket.ReadString(); // Sender name
                    pPacket.ReadByte();   // GENDER..?
                    pPacket.ReadLong();   // Sent at?
                    pPacket.ReadInt();    // Receiver ID
                    pPacket.ReadString(); // Receiver name
                    pPacket.ReadByte();
                    pPacket.ReadByte();
                    pPacket.ReadLong();   // Receive date?
                    pPacket.ReadString(); // Message
                }
            }
#else
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadShort();
                pPacket.ReadString();
            }
#endif

            Quests.DecodePQ(pConnection, pPacket);

            if (GameHelper.IsWildHunter(Stats.JobID))
            {
                pPacket.ReadByte(); // Level

                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt(); // Caught mob
            }

            Quests.DecodePQDone(pConnection, pPacket);

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                short cnt = pPacket.ReadShort();
                int   unk = pPacket.ReadInt(); // 9010040 | Conor (NPC)
                if (cnt > 0 && unk > 0)
                {
                    for (short j = 0; j < cnt; j++)
                    {
                        pPacket.ReadInt(); // 9010040 | Conor (NPC)
                        pPacket.ReadShort();
                        pPacket.ReadInt(); // 4330019 | Pink Coin Purse
                        pPacket.ReadShort();
                    }
                }
            }

            for (int i = 13; i > 0; i--)
            {
                pPacket.ReadInt(); // Stolen Skills
            }

            for (int i = 4; i > 0; i--)
            {
                pPacket.ReadInt(); // Chosen Skills?
            }

            // Inner Stats
            Abilities = new List <Tuple <byte, int, byte> >();
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                byte id      = pPacket.ReadByte(); // 'ID'
                int  skillid = pPacket.ReadInt();  // Skill ID
                byte level   = pPacket.ReadByte(); // Level
                pPacket.ReadByte();                // Rank
                Abilities.Add(new Tuple <byte, int, byte>(id, skillid, level));
            }

#if LOCALE_GMS
            {
                // V.134
                for (int i = pPacket.ReadInt(); i > 0; i--)
                {
                    pPacket.ReadString();

                    pPacket.ReadInt();
                    pPacket.ReadString();

                    for (int j = pPacket.ReadInt(); j > 0; j--)
                    {
                        pPacket.ReadByte();
                    }
                }

                pPacket.ReadByte();
            }
#endif

            Stats.HonourLevel = pPacket.ReadInt();
            Stats.HonourExp   = pPacket.ReadInt();

            {
                byte unk = pPacket.ReadByte();
                if (unk == 1)
                {
                    while (true)
                    {
                        tmp = pPacket.ReadUShort();
                        if (tmp <= 0)
                        {
                            break;
                        }

                        while (true)
                        {
                            ushort tmp2 = pPacket.ReadUShort();
                            if (tmp2 <= 0)
                            {
                                break;
                            }

                            pPacket.ReadInt();
                            pPacket.ReadInt();
                        }
                    }
                }
                else
                {
                    while (true)
                    {
                        tmp = pPacket.ReadUShort();
                        if (tmp <= 0)
                        {
                            break;
                        }

                        pPacket.ReadUShort();
                        pPacket.ReadInt();
                        pPacket.ReadInt();
                    }
                }
            }

            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
            }


            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
            }


            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
            }

#if LOCALE_EMS
            pPacket.ReadBool();
            pPacket.ReadBool();
#endif
            {
                EvolutionCards = new List <EvolutionCard>();

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    var card = new EvolutionCard();
                    card.Decode(pConnection, pPacket);
                    card.Block = 1;
                    EvolutionCards.Add(card);
                }

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    var card = new EvolutionCard();
                    card.Decode(pConnection, pPacket);
                    card.Block = 2;
                    EvolutionCards.Add(card);
                }
            }

#if LOCALE_EMS
            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
                pPacket.ReadInt();
            }
#endif

#if LOCALE_EMS
            // No farm info

            for (short i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.Skip(20);
            }
#else
            {
                // V.134
                for (byte i = pPacket.ReadByte(); i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadLong();
                }
            }

            {
                // V.134
                // FARM INFO. Creating... = not yet created farm. Else: farmname
                pPacket.ReadString(); // Creating...
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();

                pPacket.ReadInt();
                pPacket.ReadInt();
            }

#if LOCALE_GMS
            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
                pPacket.ReadInt();
            }
#endif

            {
                // V.141
                pPacket.ReadInt();
                pPacket.ReadLong(); // A bit off here, should be filetime value
                pPacket.ReadInt();
            }

            pPacket.Skip(84); // I don't even

            pPacket.ReadByte();

            {
                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadShort();
                    pPacket.ReadShort();
                }
            }

            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();

                pPacket.Skip(32);
            }

            {
                if (pPacket.ReadInt() > 0)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        pPacket.Skip(4 + 4 + 4);
                        pPacket.ReadString();
                        pPacket.Skip(4 * 7);
                        pPacket.Skip(8 * 4);
                        pPacket.Skip(4 * 4);
                        pPacket.Skip(1 * 5);
                        pPacket.Skip(4 * 3);
                        pPacket.ReadString();
                        pPacket.Skip(4 * 2);
                        pPacket.ReadByte();

                        byte tmptmp = pPacket.ReadByte();
                        if ((tmptmp & 0x01) != 0)
                        {
                            pPacket.ReadInt();
                            pPacket.ReadString();
                            pPacket.Skip(24);
                        }

                        for (int j = pPacket.ReadInt(); j > 0; j++)
                        {
                            pPacket.Skip(4 * 9);
                        }
                    }
                }
            }

            // Removed in V.141
            //pPacket.ReadInt(); // I DONT EVEN D:
#endif
        }