コード例 #1
0
        public virtual void HandleLogin(ClientConnection pConnection, MaplePacket pPacket)
        {
            int error = pPacket.ReadInt();
            pPacket.ReadShort();
            if (error != 0)
            {
                pConnection.Logger_WriteLine("Got Status: {0}", error);
                if (error == 0x07)
                {
                    pConnection.Logger_WriteLine("Already logged in!");
                }
                return;
            }

            int userid = pPacket.ReadInt();
            byte gender = pPacket.ReadByte(); // Gender or GenderSelect/PinSelect
            pPacket.ReadByte();
            short admin = pPacket.ReadShort();
            pPacket.ReadInt(); // ReadBytes(4)
            pPacket.ReadByte(); // 0x95
            string username = pPacket.ReadString(); // Username

            pPacket.ReadByte(); // 0?


            byte qban = pPacket.ReadByte(); // Quiet Ban
            DateTime qban_time = DateTime.FromFileTime(pPacket.ReadLong()); // Quiet Ban Time
            DateTime creationtime = DateTime.FromFileTime(pPacket.ReadLong()); // Creation Time
            pPacket.ReadInt(); // 78?
            pPacket.Skip(2); // 1 1
            pPacket.ReadBytes(8); // CC key

            ParseLogin(pConnection, userid, username, creationtime);
        }
        public void Decode(MaplePacket pPacket)
        {
            pPacket.ReadByte(); // ?


            Running = new Dictionary<ushort, string>();
            Done = new Dictionary<ushort, long>();

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                Running.Add(pPacket.ReadUShort(), pPacket.ReadString());
            }

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

            pPacket.ReadByte(); // ?

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                Done.Add(pPacket.ReadUShort(), pPacket.ReadLong());
            }
        }
コード例 #3
0
        public virtual void HandleLoginFromWeb(ClientConnection pConnection, MaplePacket pPacket)
        {
            byte error = pPacket.ReadByte();
            if (error != 0)
            {
                pConnection.Logger_WriteLine("Got Status: {0}", error);
                if (error == 0x07)
                {
                    pConnection.Logger_WriteLine("Already logged in!");
                }
                return;
            }

            int userid = pPacket.ReadInt();
            pPacket.ReadByte(); // Gender or GenderSelect/PinSelect
            pPacket.ReadByte();
            pPacket.ReadShort(); // Admin info!
            pPacket.ReadInt(); // ReadBytes(4)
            pPacket.ReadByte(); // 0x95
            string username = pPacket.ReadString(); // Username

            pPacket.ReadByte(); // 0?


            pPacket.ReadByte(); // Quiet Ban
            pPacket.ReadLong(); // Quiet Ban Time
            pPacket.ReadString(); // Username. Again.
            DateTime creationtime = DateTime.FromFileTime(pPacket.ReadLong()); // creation datetime
            pPacket.ReadInt();
            pPacket.ReadBytes(8); // CC key
            pPacket.ReadString();

            ParseLogin(pConnection, userid, username, creationtime);
        }
コード例 #4
0
        public void Decode(MaplePacket pPacket)
        {
            ChosenCardID = pPacket.ReadInt();

            if (pPacket.ReadBool() == false)
            {
                for (short cards = pPacket.ReadShort(); cards > 0; cards--)
                {
                    pPacket.ReadShort(); // CardID
                    pPacket.ReadByte(); // Level
                }
            }
            else
            {
                // Unknown stuff...
                pPacket.ReadShort();
                short size = pPacket.ReadShort();
                pPacket.Skip(size); // Card block

                size = pPacket.ReadShort();
                pPacket.Skip(size); // Levels
            }
        }
コード例 #5
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            var v = pPacket.ReadByte(); // ?


            Running = new Dictionary<ushort, string>();
            Done = new Dictionary<ushort, long>();

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                Running.Add(pPacket.ReadUShort(), pPacket.ReadString());
            }

            if (v == 0)
            {
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadShort(); // UNK lol
                }
            }

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadString(); // 1NX1702337
                pPacket.ReadString(); // '1' or '0 ' ?!
            }

            var hurr = pPacket.ReadByte(); // ?

            // ADDED IN v.128 !!!!
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                // New method of creating dates...
                var id = pPacket.ReadUShort();
                var date = pPacket.ReadUInt();

                long ft = DecodeTimeFromInt(pConnection, date);

                if (!Done.ContainsKey(id))
                    Done.Add(id, ft);
                else
                    pConnection.Logger_WriteLine("Duplicate Quest (Done): {0}", id);

            }

            if (hurr == 0)
            {
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Done.Add(pPacket.ReadUShort(), pPacket.ReadLong());
                }
            }
        }
コード例 #6
0
ファイル: CharacterData.cs プロジェクト: diamondo25/mapler.me
            public Ring(Ring.Type pType, MaplePacket pPacket, string pOwnName = null)
            {
                RingType = pType;
                if (pType == Type.Marriage)
                {
                    int marriageID = pPacket.ReadInt();

                    int characterID = pPacket.ReadInt();
                    int partnerID = pPacket.ReadInt();
                    pPacket.ReadShort(); // Most likely 3, marriage type?
                    int characterItemID = pPacket.ReadInt();
                    int partnerItemID = pPacket.ReadInt();
                    string characterName = pPacket.ReadString(13);
                    string partnerName = pPacket.ReadString(13);

                    if (pOwnName != FriendName)
                    {
                        FriendID = partnerID;
                        FriendName = partnerName;
                        RingCashID1 = characterItemID;
                        RingCashID2 = partnerItemID;
                    }
                    else
                    {
                        FriendID = characterID;
                        FriendName = characterName;
                        RingCashID1 = partnerItemID;
                        RingCashID2 = characterItemID;
                    }
                }
                else
                {
                    FriendID = pPacket.ReadInt();
                    FriendName = pPacket.ReadString(13);
                    RingCashID1 = pPacket.ReadLong();
                    RingCashID2 = pPacket.ReadLong();

                    if (pType == Type.Friend)
                    {
                        int itemID = pPacket.ReadInt();
                    }

                }
            }
        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);
                }
            }
        }
コード例 #8
0
ファイル: Android.cs プロジェクト: diamondo25/mapler.me
        public void Decode(MaplePacket pPacket)
        {
            this.ID = pPacket.ReadInt();
            this.Type = pPacket.ReadByte();

            pPacket.ReadShort(); // X
            pPacket.ReadShort(); // Y
            pPacket.ReadByte(); // Stance
            pPacket.ReadShort(); // Foothold

            this.Skin = (byte)pPacket.ReadShort();
            this.Hair = pPacket.ReadShort();
            this.Face = pPacket.ReadShort();
            this.Name = pPacket.ReadString();

            this.Equips = new int[7];
            for (int i = 0; i < 7; i++)
                this.Equips[i] = pPacket.ReadInt();
        }
        public override void Decode(MaplePacket pPacket)
        {
            base.Decode(pPacket);

            Amount = pPacket.ReadShort();
            CraftName = pPacket.ReadString();
            Flags = pPacket.ReadShort();

            int itemtype = ItemID / 10000;
            if (itemtype == 233 || itemtype == 207)
                UniqueID = pPacket.ReadLong();
        }
        public override void Decode(MaplePacket pPacket)
        {
            base.Decode(pPacket);


            this.Slots = pPacket.ReadByte();
            this.Scrolls = pPacket.ReadByte();
            this.Str = pPacket.ReadShort();
            this.Dex = pPacket.ReadShort();
            this.Int = pPacket.ReadShort();
            this.Luk = pPacket.ReadShort();
            this.HP = pPacket.ReadShort();
            this.MP = pPacket.ReadShort();
            this.Watk = pPacket.ReadShort();
            this.Matk = pPacket.ReadShort();
            this.Wdef = pPacket.ReadShort();
            this.Mdef = pPacket.ReadShort();
            this.Acc = pPacket.ReadShort();
            this.Avo = pPacket.ReadShort();
            this.Hands = pPacket.ReadShort();
            this.Speed = pPacket.ReadShort();
            this.Jump = pPacket.ReadShort();

            this.Name = pPacket.ReadString();
            this.Flags = pPacket.ReadShort();

            pPacket.ReadByte(); // Increases Skill
            this.Level = pPacket.ReadByte();

            pPacket.ReadInt();
            pPacket.ReadInt(); // 
            this.ViciousHammer = pPacket.ReadInt();

            pPacket.ReadShort(); // PVP damage

            pPacket.ReadByte();
            pPacket.ReadByte();

            this.Potential1 = pPacket.ReadShort();
            this.Potential2 = pPacket.ReadShort();
            this.Potential3 = pPacket.ReadShort();
            this.Potential4 = pPacket.ReadShort();
            this.Potential5 = pPacket.ReadShort();

            pPacket.ReadShort(); // New?

            this.SocketState = pPacket.ReadShort();
            this.Socket1 = pPacket.ReadShort();
            this.Socket2 = pPacket.ReadShort();
            this.Socket3 = pPacket.ReadShort();

            pPacket.ReadLong();

            pPacket.ReadLong();

            pPacket.ReadInt();
        }
コード例 #11
0
        public override void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            base.Decode(pConnection, pPacket);

            Petname = pPacket.ReadString(13);
            Level = pPacket.ReadByte();
            Closeness = pPacket.ReadShort();
            Fullness = pPacket.ReadByte();

            this.Expires = pPacket.ReadLong();
            pPacket.Skip(2 + 2 + 4 + 2 + 1 + 4 + 4 + 2);
            // Last 2:
            // - int: -1
            // - short: 100
            // V.132: + 2
        }
コード例 #12
0
        public virtual void HandleChangeMap(ClientConnection pConnection, MaplePacket pPacket)
        {

            int tmp = pPacket.ReadShort();
            pPacket.Skip(tmp * (4 + 4));

            int channelid = pPacket.ReadInt();
            pConnection.ChannelID = (byte)channelid;

#if LOCALE_EMS
            pPacket.ReadByte();
#endif
            pPacket.Skip(1 + 4);
            pPacket.Skip(1); // Portals taken
            pPacket.Skip(4);

            bool isConnecting = pPacket.ReadBool();

            if (!isConnecting && pConnection.CharData == null)
            {
                return;
            }

            pConnection._CharactersInMap.Clear();

            tmp = pPacket.ReadShort(); // Contains Message (Not used anymore lol.)
            if (tmp > 0)
            {
                pPacket.ReadString(); // Title
                for (int i = 0; i < tmp; i++)
                {
                    pPacket.ReadString(); // Line N
                }
            }

            if (isConnecting)
            {
                pPacket.Skip(12); // RNGs

                pConnection.Logger_WriteLine("--------- Started parsing Character Info ----------");

                CharacterData data = new CharacterData();
                data.Decode(pConnection, pPacket);

                pConnection.Logger_WriteLine("--------- Done parsing Character Info ----------");

                // Quick duplicate check
                Tuple<int, byte, byte, ushort> conflicted = null;
                using (var reader = MySQL_Connection.Instance.RunQuery("SELECT id, level, world_id, job FROM characters WHERE id <> " + data.Stats.ID + " AND name = " + MySQL_Connection.Escape(data.Stats.Name)) as MySql.Data.MySqlClient.MySqlDataReader)
                {
                    if (reader.Read())
                    {
                        // CONFLICTS
                        conflicted = new Tuple<int, byte, byte, ushort>(reader.GetInt32(0), reader.GetByte(1), reader.GetByte(2), reader.GetUInt16(3));
                    }
                }
                if (conflicted == null)
                {
                    if (!data.SaveData(pConnection))
                        return;

                    pConnection.CharData = data;

                    pConnection.Logger_WriteLine("--------- Saved parsed Character Info ----------");


                    pConnection.LastLoggedCharacterName = pConnection.CharData.Stats.Name;
                    pConnection.LastLoggedDate = pConnection.CharData.Stats.DateThing.ToString();

                    pConnection.LogFilename += "-" + pConnection.CharacterInternalID;

                    pConnection.LastExpPoint = (byte)EXPTable.GetLevelPercentage(data.Stats.Level, data.Stats.EXP);

                    pConnection.SendInfoText("Your character {0} has been saved!", pConnection.CharData.Stats.Name);

                    // Save SessionRestart Info
                    SessionRestartCache.Instance.StoreInfo(pConnection.IP, pConnection.MachineID, pConnection.CharacterID, pConnection.WorldID);

                }
                else
                {
                    pConnection.LogFilename += "-(CONFLICT)" + data.Stats.Name;

                    pConnection.Logger_WriteLine("!!!!!! FOUND CHARACTER NAME CONFLICT ! Expected Character ID {0}, found Character ID {1} in database!", data.Stats.ID, conflicted.Item1);
                    pConnection.Logger_WriteLine("Level diff: {0} - {1}", data.Stats.Level, conflicted.Item3);
                    pConnection.Logger_WriteLine("Job diff: {0} - {1}", data.Stats.JobID, conflicted.Item4);
                    pConnection.Logger_WriteLine("World diff: {0} - {1}", pConnection.WorldID, conflicted.Item2);
                    pConnection.SendInfoText("A different character has already this name! Delete this character via the website first!");
                }


                Queries.SaveServerIP(pConnection.ConnectedToIP, pConnection.ConnectedToPort, GameHelper.GetAllianceWorldID(pConnection.WorldID), pConnection.ChannelID);
            }
            else
            {
                pPacket.ReadByte();

                int mapid = pPacket.ReadInt();
                byte mappos = pPacket.ReadByte();
                pConnection.Logger_WriteLine("New MapID: {0} ({1})", mapid, mappos);

                pConnection.CharData.Stats.MapID = mapid;
                pConnection.CharData.Stats.MapPos = mappos;

                int hp = pPacket.ReadInt();
                pConnection.CharData.Stats.HP = hp;

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

                MySQL_Connection.Instance.RunQuery(string.Format("UPDATE characters SET chp = {0}, map = {1}, pos = {2} WHERE internal_id = {3}", hp, mapid, mappos, pConnection.CharacterInternalID));
            }

            pPacket.ReadLong();
            //DateTime servertime = DateTime.FromFileTime(pPacket.ReadLong());
            pPacket.ReadInt(); // 100?
            pPacket.ReadByte(); // 0
            pPacket.ReadByte(); // 0
            pPacket.ReadByte(); // 1

            if (pPacket.Position != pPacket.Length)
            {
                pConnection.Logger_WriteLine("Data not fully read. Halp.: {0} of {1} read", pPacket.Position, pPacket.Length);
            }


            pConnection.SendTimeUpdate();
        }
コード例 #13
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);
                    }
                }
            }
        }
コード例 #14
0
        public void Decode(MaplePacket pPacket)
        {
            this.ID = pPacket.ReadInt();
            this.Name = pPacket.ReadString(13);

            Logger.WriteLine("FOUND CHARACTER {0} (ID: {1})", this.Name, this.ID);

            this.Gender = pPacket.ReadByte();
            this.Skin = pPacket.ReadByte();
            this.Face = pPacket.ReadInt();
            this.Hair = pPacket.ReadInt();

#if LOCALE_EMS
            this.Pets = new long[3] { 0, 0, 0 }; // Not defined!?
#else
            this.Pets = new long[3] { pPacket.ReadLong(), pPacket.ReadLong(), pPacket.ReadLong() };
#endif

            this.Level = pPacket.ReadByte();


            this.JobID = pPacket.ReadShort();
            this.Str = pPacket.ReadShort();
            this.Dex = pPacket.ReadShort();
            this.Int = pPacket.ReadShort();
            this.Luk = pPacket.ReadShort();
            this.HP = pPacket.ReadInt();
            this.MaxHP = pPacket.ReadInt();
            this.MP = pPacket.ReadInt();
            this.MaxMP = pPacket.ReadInt();

            this.AP = pPacket.ReadShort();

            SPData = new List<KeyValuePair<byte, int>>();
            if (GameHelper.IsExtendedSPJob(this.JobID))
            {
                byte amnt = pPacket.ReadByte();
                List<byte> haslist = new List<byte>();
                for (int j = 0; j < amnt; j++)
                {
                    byte v1 = pPacket.ReadByte(); // Job ID
                    int v2 = pPacket.ReadInt(); // Amount
                    SPData.Add(new KeyValuePair<byte, int>(v1, v2));

                    haslist.Add(v1);
                }
                for (byte j = 1; j < 20; j++)
                {
                    if (!haslist.Contains(j))
                        SPData.Add(new KeyValuePair<byte, int>(j, 0));
                }
            }
            else
            {
                SPData.Add(new KeyValuePair<byte, int>(0, pPacket.ReadShort()));
            }

            this.EXP = pPacket.ReadLong();
            this.Fame = pPacket.ReadInt();
#if LOCALE_GMS
            pPacket.ReadInt(); // Gacha EXP
            pPacket.ReadInt(); // V.141, unknown
#elif LOCALE_EMS
            pPacket.ReadLong();
            pPacket.ReadLong();
#endif
            this.MapID = pPacket.ReadInt();
            this.MapPos = pPacket.ReadByte();

#if LOCALE_GMS
            pPacket.ReadInt();
#endif
            this.JobSubID = pPacket.ReadShort();


            if (this.JobID / 100 == 31 || this.JobID / 100 == 36 || this.JobID == 3001 || this.JobID == 3002)
            {
                this.DemonMark = pPacket.ReadInt();
            }

            //this.JobType = pPacket.ReadByte();
            pPacket.ReadByte(); // Fatigue ?

            this.DateThing = pPacket.ReadInt(); // YYYYMMDDhh

            this.Traits = new int[6] { 
                pPacket.ReadInt(), // Charisma
                pPacket.ReadInt(), // Insight
                pPacket.ReadInt(), // Willpower
                pPacket.ReadInt(), // Craft/Diligence
                pPacket.ReadInt(), // Empathy
                pPacket.ReadInt()  // Charm
            };

            this.TraitsToday = new ushort[6] { 
                pPacket.ReadUShort(), // Charisma
                pPacket.ReadUShort(), // Insight
                pPacket.ReadUShort(), // Willpower
                pPacket.ReadUShort(), // Craft/Diligence
                pPacket.ReadUShort(), // Empathy
                pPacket.ReadUShort()  // Charm
            };


            pPacket.Skip(21 - 12); // Leftover: 9 bytes

            pPacket.ReadInt();

            pPacket.ReadByte();
            pPacket.ReadInt();
            pPacket.ReadByte();
            pPacket.ReadByte();
            pPacket.ReadInt();
            pPacket.ReadByte();

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

            pPacket.ReadInt();
            pPacket.ReadByte(); // != 0 check

            // List of Parttime jobs?
            for (int i = 1; i <= 9; i++)
            {
                pPacket.ReadInt(); // Character ID
                pPacket.ReadByte(); // Level
                pPacket.ReadInt(); // Job ID
            }

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

#if LOCALE_EMS
            pPacket.ReadInt();
#endif
        }
コード例 #15
0
ファイル: CharacterData.cs プロジェクト: diamondo25/mapler.me
 public void Decode(ClientConnection pConnection, MaplePacket pPacket)
 {
     ID = pPacket.ReadShort();
     ItemID = pPacket.ReadInt();
     Level = (byte)pPacket.ReadInt();
 }
コード例 #16
0
        public virtual void HandleInventoryUpdate(ClientConnection pConnection, MaplePacket pPacket)
        {
            CharacterInventory inventory = pConnection.CharData.Inventory;

            byte type1 = pPacket.ReadByte();
            byte items = pPacket.ReadByte();
            byte type3 = pPacket.ReadByte();
            if (type3 == 0) // Add or update item
            {
                for (var amnt = 0; amnt < items; amnt++)
                {
                    byte type4 = pPacket.ReadByte();
                    byte inv = pPacket.ReadByte();
                    short slot = pPacket.ReadShort();
                    inv -= 1;

                    if (type4 == 0) // New Item
                    {

                        ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);

                        if (inv == 0)
                        {
                            // Equip
                            byte internalInventory = CharacterInventory.GetEquipInventoryFromSlot(slot);
                            slot = CharacterInventory.CorrectEquipSlot(internalInventory, slot);

                            if (!inventory.EquipmentItems[internalInventory].ContainsKey(slot))
                                inventory.EquipmentItems[internalInventory].Add(slot, item as ItemEquip);
                            else
                                inventory.EquipmentItems[internalInventory][slot] = item as ItemEquip;
                        }
                        else
                        {
                            if (!inventory.InventoryItems[inv - 1].ContainsKey((byte)slot))
                                inventory.InventoryItems[inv - 1].Add((byte)slot, item);
                            else
                                inventory.InventoryItems[inv - 1][(byte)slot] = item;
                        }

                        using (InsertQueryBuilder itemsTable = new InsertQueryBuilder("items"))
                        {
                            itemsTable.OnDuplicateUpdate = true;
                            Queries.SaveItem(pConnection, inv, slot, item, itemsTable);
                            itemsTable.RunQuery();

                        }

                        if (item is ItemPet)
                        {
                            var pet = item as ItemPet;
                            using (InsertQueryBuilder petTable = new InsertQueryBuilder("pets"))
                            {
                                petTable.OnDuplicateUpdate = true;
                                Queries.SavePet(pConnection.CharacterInternalID, pet, petTable);
                                petTable.RunQuery();
                            }
                        }

                    }
                    else if (type4 == 1) // Update amount
                    {
                        short amount = pPacket.ReadShort();
                        if (inv == 0)
                        {
                            pConnection.Logger_WriteLine("WUTWUT"); // Should _never_ happen
                            continue;
                        }

                        ItemBase item = inventory.InventoryItems[inv - 1][(byte)slot];
                        item.Amount = amount;

                        AccountDataCache.Instance.SetChecksumOfSlot(pConnection.CharacterID, pConnection.WorldID, inv, slot, item.GetChecksum());

                        using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                        {
                            itemTable.SetColumn("amount", amount);
                            itemTable.SetColumn("checksum", item.GetChecksum());
                            itemTable.SetWhereColumn("inventory", inv);
                            itemTable.SetWhereColumn("slot", slot);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                            MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                        }


                    }
                    else if (type4 == 2) // Swap
                    {
                        short slotfrom = slot;
                        short slotto = pPacket.ReadShort();

                        bool founditem = false;

                        if (inv == 0)
                        {
                            // Equips!
                            byte internalInventoryFrom = CharacterInventory.GetEquipInventoryFromSlot(slotfrom);
                            byte internalInventoryTo = CharacterInventory.GetEquipInventoryFromSlot(slotto);
                            slotfrom = CharacterInventory.CorrectEquipSlot(internalInventoryFrom, slotfrom);
                            slotto = CharacterInventory.CorrectEquipSlot(internalInventoryTo, slotto);

                            // Switch Equips
                            ItemEquip item = inventory.EquipmentItems[internalInventoryFrom][slotfrom];
                            if (inventory.EquipmentItems[internalInventoryTo].ContainsKey(slotto))
                            {
                                inventory.EquipmentItems[internalInventoryFrom][slotfrom] =
                                    inventory.EquipmentItems[internalInventoryTo][slotto];

                                inventory.EquipmentItems[internalInventoryTo].Remove(slotto); // Remove item
                                founditem = true;
                            }
                            else
                            {
                                inventory.EquipmentItems[internalInventoryFrom].Remove(slotfrom);
                            }
                            inventory.EquipmentItems[internalInventoryTo].Add(slotto, item);
                        }
                        else
                        {
                            // Switch Items
                            ItemBase item = inventory.InventoryItems[inv - 1][(byte)slotfrom];
                            if (inventory.InventoryItems[inv - 1].ContainsKey((byte)slotto))
                            {
                                inventory.InventoryItems[inv - 1][(byte)slotfrom] =
                                    inventory.InventoryItems[inv - 1][(byte)slotto];
                                inventory.InventoryItems[inv - 1].Remove((byte)slotto); // Remove item
                                founditem = true;
                            }
                            else
                            {
                                inventory.InventoryItems[inv - 1].Remove((byte)slotfrom);
                            }
                            inventory.InventoryItems[inv - 1].Add((byte)slotto, item);
                        }

                        if (founditem) // New slot contained item
                        {
                            using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                            {
                                itemTable.SetColumn("slot", slotfrom + 3000);
                                itemTable.SetWhereColumn("inventory", inv);
                                itemTable.SetWhereColumn("slot", slotto);
                                itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                                MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                            }
                        }

                        using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                        {
                            itemTable.SetColumn("slot", slotto);
                            itemTable.SetWhereColumn("inventory", inv);
                            itemTable.SetWhereColumn("slot", slotfrom);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                            MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                        }

                        if (founditem) // Fix other slot
                        {
                            using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                            {
                                itemTable.SetColumn("slot", slotfrom);
                                itemTable.SetWhereColumn("inventory", inv);
                                itemTable.SetWhereColumn("slot", slotfrom + 3000);
                                itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                                MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                            }
                        }
                    }
                    else if (type4 == 3)
                    {
                        // Drop/delete item.

                        if (inv == 0)
                        {
                            // Equips!
                            byte internalInventory = CharacterInventory.GetEquipInventoryFromSlot(slot);
                            slot = CharacterInventory.CorrectEquipSlot(internalInventory, slot);

                            if (inventory.EquipmentItems[internalInventory].ContainsKey(slot))
                            {
                                inventory.EquipmentItems[internalInventory].Remove(slot);
                                AccountDataCache.Instance.DeleteItemChecksum(pConnection, 0, slot);
                            }
                            else
                                pConnection.Logger_WriteLine("!!! Could not find item @ {0} {1}", inv, slot);
                        }
                        else
                        {
                            if (inventory.InventoryItems[inv - 1].ContainsKey((byte)slot))
                            {
                                inventory.InventoryItems[inv - 1].Remove((byte)slot);
                                AccountDataCache.Instance.DeleteItemChecksum(pConnection, (ushort)(inv - 1), slot);
                            }
                            else
                                pConnection.Logger_WriteLine("!!! Could not find item @ {0} {1}", inv, slot);


                        }

                        using (DeleteQueryBuilder itemTable = new DeleteQueryBuilder("items"))
                        {
                            itemTable.SetWhereColumn("inventory", inv);
                            itemTable.SetWhereColumn("slot", slot);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);
                            itemTable.RunQuery();
                        }
                    }

                    else if (type4 == 4)
                    {
                        pPacket.ReadLong(); // Unknown..?
                    }
                    else if (type4 == 5)
                    {
                        // 'Swap' items from and to bags
                        inv -= 1;

                        short from = slot;
                        byte slotfrom = (byte)(from % 100);
                        byte bagfrom = (byte)(from / 100);

                        short to = pPacket.ReadShort();
                        byte slotto = (byte)(to % 100);
                        byte bagto = (byte)(to / 100);


                        slotfrom -= 1;
                        slotto -= 1;
                        if (bagto == 0)
                            bagto = 255;
                        else
                            bagto -= 1;
                        if (bagfrom == 0)
                            bagfrom = 255;
                        else
                            bagfrom -= 1;


                        ushort invto = bagto == 255 ? inv : GameHelper.GetBagID(bagto, inv);
                        ushort invfrom = bagfrom == 255 ? inv : GameHelper.GetBagID(bagfrom, inv);


                        if (
                            (bagfrom != 255 && bagto != 255) ||
                            (bagfrom == bagto) || // Check if the item is being moved to itself or something

                            (bagfrom == 255 && !inventory.InventoryItems[inv].ContainsKey(slotfrom)) ||
                            (bagfrom != 255 && (!inventory.BagItems.ContainsKey(invfrom) || !inventory.BagItems[invfrom].Items.ContainsKey(slotfrom))) ||

                            (bagto != 255 && !inventory.BagItems.ContainsKey(invto)) // Only check if bag exists
                            )
                        {
                            pConnection.Logger_WriteLine("Invalid item movement in bag !!!");
                            continue;
                        }

                        bool founditem = false;
                        if (bagfrom == 255)
                        {
                            // Move to bag
                            ItemBase ib = inventory.InventoryItems[inv][slotfrom];
                            if (inventory.BagItems[invto].Items.ContainsKey(slotto))
                            {
                                inventory.InventoryItems[inv][slotfrom] = inventory.BagItems[invto].Items[slotto];
                                inventory.BagItems[invto].Items.Remove(slotto);
                                founditem = true;
                            }

                            inventory.BagItems[invto].Items.Add(slotto, ib);



                        }
                        else
                        {
                            // Move to normal slot
                            ItemBase ib = inventory.BagItems[invfrom].Items[slotfrom];
                            if (inventory.InventoryItems[inv].ContainsKey(slotto))
                            {
                                inventory.BagItems[invfrom].Items[slotfrom] = inventory.InventoryItems[inv][slotto];
                                inventory.InventoryItems[inv].Remove(slotto);
                            }

                            inventory.InventoryItems[inv].Add(slotto, ib);



                            using (InsertQueryBuilder itemsTable = new InsertQueryBuilder("items"))
                            {
                                itemsTable.OnDuplicateUpdate = true;
                                Queries.SaveItem(pConnection, inv, slot, ib, itemsTable);
                                itemsTable.RunQuery();
                            }


                        }

                        /*
                         * Item A: item being used to move/swap | inv 3, slot 21 (Etc) | slotfrom, invfrom
                         * Item B: item that is being swapped with A | inv 11, slot 3 (Bag 2) | slotto, invto
                         * 
                         * Move B to a temp slot, to the new inventory: inv 11 -> inv 3, slot 3 -> slot 3021
                         * Move A to B: inv 3 -> inv 11, slot 21 -> slot 3
                         * Move B to A: slot 3021 -> slot 21
                         * 
                        */


                        if (founditem) // New slot contained item
                        {
                            // Temporary moving item
                            using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                            {
                                itemTable.SetColumn("slot", slotfrom + 3000);
                                itemTable.SetColumn("inventory", invfrom);
                                itemTable.SetWhereColumn("inventory", invto);
                                itemTable.SetWhereColumn("slot", slotto);
                                itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                                MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                            }
                        }

                        using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                        {
                            itemTable.SetColumn("slot", slotto);
                            itemTable.SetColumn("inventory", invto);
                            itemTable.SetWhereColumn("inventory", invfrom);
                            itemTable.SetWhereColumn("slot", slotfrom);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                            MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                        }

                        if (founditem) // Fix other slot
                        {
                            using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                            {
                                itemTable.SetColumn("slot", slotfrom);
                                itemTable.SetWhereColumn("inventory", invfrom);
                                itemTable.SetWhereColumn("slot", slotfrom + 3000);
                                itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                                MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                            }
                        }
                    }
                    else if (type4 == 6)
                    {
                        // Update bag item amount
                        inv -= 1;

                        short from = slot;
                        byte slotfrom = (byte)(from % 100);
                        byte bagfrom = (byte)(from / 100);

                        short amount = pPacket.ReadShort();


                        slotfrom -= 1;
                        if (bagfrom == 0)
                        {
                            pConnection.Logger_WriteLine("Invalid item bag!");
                            continue;
                        }
                        else
                            bagfrom -= 1;

                        ushort invfrom = GameHelper.GetBagID(bagfrom, inv);

                        if (
                            !inventory.BagItems.ContainsKey(invfrom) || !inventory.BagItems[invfrom].Items.ContainsKey(slotfrom)
                            )
                        {
                            pConnection.Logger_WriteLine("Invalid item movement in bag (item did not exist)!!!");
                            continue;
                        }



                        ItemBase item = inventory.BagItems[invfrom].Items[slotfrom];
                        item.Amount = amount;

                        AccountDataCache.Instance.SetChecksumOfSlot(pConnection.CharacterID, pConnection.WorldID, inv, slot, item.GetChecksum());

                        using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                        {
                            itemTable.SetColumn("amount", amount);
                            itemTable.SetColumn("checksum", item.GetChecksum());
                            itemTable.SetWhereColumn("inventory", invfrom);
                            itemTable.SetWhereColumn("slot", slot);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                            MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                        }
                    }
                    else if (type4 == 7)
                    {
                        // Delete/drop bag item D:
                        inv -= 1;

                        short from = slot;
                        byte slotfrom = (byte)(from % 100);
                        byte bagfrom = (byte)(from / 100);

                        slotfrom -= 1;
                        bagfrom -= 1;
                        ushort invfrom = GameHelper.GetBagID(bagfrom, inv);


                        using (DeleteQueryBuilder itemTable = new DeleteQueryBuilder("items"))
                        {
                            itemTable.SetWhereColumn("inventory", invfrom);
                            itemTable.SetWhereColumn("slot", slotfrom);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                            MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                        }
                    }
                    else if (type4 == 8)
                    {
                        // Swap/move item in bags
                        inv -= 1;

                        short from = slot;
                        byte slotfrom = (byte)(from % 100);
                        byte bagfrom = (byte)(from / 100);

                        short to = pPacket.ReadShort();
                        byte slotto = (byte)(to % 100);
                        byte bagto = (byte)(to / 100);

                        slotfrom -= 1;
                        slotto -= 1;
                        bagto -= 1;
                        bagfrom -= 1;


                        ushort invto = GameHelper.GetBagID(bagto, inv);
                        ushort invfrom = GameHelper.GetBagID(bagfrom, inv);


                        if (!inventory.BagItems.ContainsKey(invfrom) || !inventory.BagItems.ContainsKey(invto))
                        {
                            pConnection.Logger_WriteLine("Invalid item movement in bag");
                            continue;
                        }

                        if (!inventory.BagItems[invfrom].Items.ContainsKey(slotfrom))
                        {
                            pConnection.Logger_WriteLine("Invalid item movement in bag (item not found)");
                            continue;
                        }

                        ItemBase item = inventory.BagItems[invfrom].Items[slotfrom];

                        bool founditem = false;

                        if (inventory.BagItems[invto].Items.ContainsKey(slotto))
                        {
                            // Swap

                            inventory.BagItems[invfrom].Items[slotfrom] = inventory.BagItems[invto].Items[slotto];
                            inventory.BagItems[invto].Items.Remove(slotto); // Delete item
                            founditem = true;
                        }
                        inventory.BagItems[invto].Items.Add(slotto, item);




                        if (founditem) // New slot contained item
                        {
                            // Temporary moving item
                            using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                            {
                                itemTable.SetColumn("slot", slotfrom + 3000);
                                itemTable.SetColumn("inventory", invfrom);
                                itemTable.SetWhereColumn("inventory", invto);
                                itemTable.SetWhereColumn("slot", slotto);
                                itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                                MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                            }
                        }

                        using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                        {
                            itemTable.SetColumn("slot", slotto);
                            itemTable.SetColumn("inventory", invto);
                            itemTable.SetWhereColumn("inventory", invfrom);
                            itemTable.SetWhereColumn("slot", slotfrom);
                            itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                            MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                        }

                        if (founditem) // Fix other slot
                        {
                            using (UpdateQueryBuilder itemTable = new UpdateQueryBuilder("items"))
                            {
                                itemTable.SetColumn("slot", slotfrom);
                                itemTable.SetWhereColumn("inventory", invfrom);
                                itemTable.SetWhereColumn("slot", slotfrom + 3000);
                                itemTable.SetWhereColumn("character_id", pConnection.CharacterInternalID);

                                MySQL_Connection.Instance.RunQuery(itemTable.ToString());
                            }
                        }
                    }
                    else if (type4 == 9)
                    {
                        // Add item directly to bag
                        inv -= 1;

                        ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);

                        short from = slot;
                        byte slotfrom = (byte)(from % 100);
                        byte bagfrom = (byte)(from / 100);

                        slotfrom -= 1;
                        bagfrom -= 1;
                        ushort invfrom = GameHelper.GetBagID(bagfrom, inv);

                        if (!inventory.BagItems.ContainsKey(invfrom)) continue;

                        inventory.BagItems[invfrom].Items[slotfrom] = item;


                        using (InsertQueryBuilder itemsTable = new InsertQueryBuilder("items"))
                        {
                            itemsTable.OnDuplicateUpdate = true;
                            Queries.SaveItem(pConnection, invfrom, slotfrom, item, itemsTable);
                            itemsTable.RunQuery();

                        }
                        if (item is ItemPet)
                        {
                            var pet = item as ItemPet;
                            using (InsertQueryBuilder petTable = new InsertQueryBuilder("pets"))
                            {
                                petTable.OnDuplicateUpdate = true;
                                Queries.SavePet(pConnection.CharacterInternalID, pet, petTable);
                                petTable.RunQuery();
                            }
                        }
                    }
                    else if (type4 == 10)
                    {
                        pConnection.Logger_WriteLine("Player probably removed some bag item... O.o?");
                    }
                }
            }
            pConnection.SendTimeUpdate();
        }
        public void Decode(MaplePacket pPacket)
        {
            Stats = new GW_CharacterStat();
            Stats.Decode(pPacket);

            this.BuddylistSize = pPacket.ReadByte();

            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); // .-.

            // Unknown stuff here

            int amount = pPacket.ReadInt();
            UnknownIntegerList = new List<UnknownListOfIntegers>();
            for (int i = 0; i < amount; i++)
            {
                UnknownListOfIntegers vals = new UnknownListOfIntegers();
                vals.Decode(pPacket);
                UnknownIntegerList.Add(vals);
            }


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

            UnknownIntegerListNumber2 = new List<int>();
            while (true)
            {
                int unkval = pPacket.ReadInt();
                if (unkval == -1) break;
                UnknownIntegerListNumber2.Add(unkval);
            }

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

            {
                UnknownIntegerListNumber4 = new Dictionary<long, long>();
                amount = pPacket.ReadInt();
                for (int i = 0; i < amount; i++)
                {
                    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(pPacket);

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

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

            // Couple
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadBytes(33);
            }

            // Friend
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadBytes(37);
            }

            // Marriage
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadBytes(48);
            }

            Inventory.DecodeTeleportRocks(pPacket);


        }
コード例 #18
0
        public virtual void HandleAbilityInfoUpdate(ClientConnection pConnection, MaplePacket pPacket)
        {
            pPacket.ReadByte(); // Unlock
            if (pPacket.ReadBool() == false) return;

            var stat = new Tuple<byte, int, byte>((byte)pPacket.ReadShort(), pPacket.ReadInt(), (byte)pPacket.ReadShort());
            pPacket.ReadShort();

            using (InsertQueryBuilder table = new InsertQueryBuilder("character_abilities"))
            {
                table.OnDuplicateUpdate = true;

                table.AddColumn("character_id");
                table.AddColumn("id");
                table.AddColumn("skill_id", true);
                table.AddColumn("level", true);


                table.AddRow(
                    pConnection.CharacterInternalID,
                    stat.Item1,
                    stat.Item2,
                    stat.Item3
                    );

                table.RunQuery();
            }
        }
コード例 #19
0
        public virtual void HandleStatUpdate(ClientConnection pConnection, MaplePacket pPacket)
        {
            pPacket.ReadByte();
            long updateFlag = pPacket.ReadLong();
            if (updateFlag == 0) return; // Fake Update -.- / Unstuck

            bool didsomething = false;

            if (CheckFlag(updateFlag, 1)) // Skin
            {
                didsomething = true;
                pConnection.CharData.Stats.Skin = pPacket.ReadByte();
            }
            if (CheckFlag(updateFlag, 2)) // Eyes
            {
                didsomething = true;
                pConnection.CharData.Stats.Face = pPacket.ReadInt();
            }
            if (CheckFlag(updateFlag, 4)) // Eyes
            {
                didsomething = true;
                pConnection.CharData.Stats.Hair = pPacket.ReadInt();
            }
            if (CheckFlag(updateFlag, 8))
            {
                didsomething = true;
                pConnection.CharData.Stats.Pets[0] = pPacket.ReadLong();
            }
            if (CheckFlag(updateFlag, 0x80000))
            {
                var value = pPacket.ReadLong();
                pConnection.Logger_WriteLine("0x80000 | {0}", value);
            }
            if (CheckFlag(updateFlag, 0x100000))
            {
                var value = pPacket.ReadLong();
                pConnection.Logger_WriteLine("0x100000 | {0}", value);
            }
            if (CheckFlag(updateFlag, 0x10))
            {
                didsomething = true;
                var level = pPacket.ReadByte();
                Timeline.Instance.PushLevelUP(pConnection, level);
                pConnection.CharData.Stats.Level = level;
                pConnection.Logger_WriteLine("{0} leveled up to level {1}!!!", pConnection.CharData.Stats.Name, level);
            }
            if (CheckFlag(updateFlag, 0x20))
            {
                didsomething = true;
                var jobid = pPacket.ReadShort();
                Timeline.Instance.PushJobUP(pConnection, (ushort)jobid);
                pConnection.CharData.Stats.JobID = jobid;
                pConnection.Logger_WriteLine("{0} changed to job {1}!!!", pConnection.CharData.Stats.Name, jobid);
            }
            if (CheckFlag(updateFlag, 0x40))
            {
                didsomething = true;
                pConnection.CharData.Stats.Str = pPacket.ReadShort();
            }
            if (CheckFlag(updateFlag, 0x80))
            {
                didsomething = true;
                pConnection.CharData.Stats.Dex = pPacket.ReadShort();
            }
            if (CheckFlag(updateFlag, 0x100))
            {
                didsomething = true;
                pConnection.CharData.Stats.Int = pPacket.ReadShort();
            }
            if (CheckFlag(updateFlag, 0x200))
            {
                didsomething = true;
                pConnection.CharData.Stats.Luk = pPacket.ReadShort();
            }
            if (CheckFlag(updateFlag, 0x400))
            {
                didsomething = true;
                pConnection.CharData.Stats.HP = pPacket.ReadInt();
            }
            if (CheckFlag(updateFlag, 0x800))
            {
                didsomething = true;
                pConnection.CharData.Stats.MaxHP = pPacket.ReadInt();
            }
            if (CheckFlag(updateFlag, 0x1000))
            {
                didsomething = true;
                pConnection.CharData.Stats.MP = pPacket.ReadInt();
            }
            if (CheckFlag(updateFlag, 0x2000))
            {
                didsomething = true;
                pConnection.CharData.Stats.MaxMP = pPacket.ReadInt();
            }
            if (CheckFlag(updateFlag, 0x4000))
            {
                didsomething = true;
                pConnection.CharData.Stats.AP = pPacket.ReadShort();
            }
            if (CheckFlag(updateFlag, 0x8000))
            {
                didsomething = true;

                short a1 = pConnection.CharData.Stats.JobID;
                pConnection.CharData.Stats.SPData.Clear();

                if (GameHelper.IsExtendedSPJob(pConnection.CharData.Stats.JobID))
                {

                    byte amnt = pPacket.ReadByte();
                    List<byte> haslist = new List<byte>();
                    for (int j = 0; j < amnt; j++)
                    {
                        byte v1 = pPacket.ReadByte(); // Job ID
                        int v2 = pPacket.ReadInt(); // Amount
                        pConnection.CharData.Stats.SPData.Add(new KeyValuePair<byte, int>(v1, v2));

                        haslist.Add(v1);
                    }
                    for (byte j = 1; j < 20; j++)
                    {
                        if (!haslist.Contains(j))
                            pConnection.CharData.Stats.SPData.Add(new KeyValuePair<byte, int>(j, 0));
                    }

                }
                else
                {
                    pConnection.CharData.Stats.SPData.Add(new KeyValuePair<byte, int>(0, pPacket.ReadShort()));
                }
            }

            if (CheckFlag(updateFlag, 0x10000))
            {
                didsomething = true;
                long newexp = pPacket.ReadLong();
                byte point = (byte)EXPTable.GetLevelPercentage(pConnection.CharData.Stats.Level, newexp);

                if (pConnection.LastExpPoint != point)
                {
                    // Ohhh
                    Timeline.Instance.PushExpPoint(pConnection, point);
                }

                pConnection.CharData.Stats.EXP = newexp;
                pConnection.LastExpPoint = point;

            }

            if (CheckFlag(updateFlag, 0x20000))
            {
                didsomething = true;
                int fame = pPacket.ReadInt();
                Timeline.Instance.PushGotFame(pConnection, fame - pConnection.CharData.Stats.Fame, fame);
                pConnection.CharData.Stats.Fame = fame;
            }

            if (CheckFlag(updateFlag, 0x40000))
            {
                didsomething = true;
                pConnection.CharData.Stats.Mesos = pPacket.ReadLong();
            }
            if (CheckFlag(updateFlag, 0x200000))
            {
                var value = pPacket.ReadInt();
                pConnection.Logger_WriteLine("0x200000 | {0}", value);
            }

            if (CheckFlag(updateFlag, 0x400000))
            {
                var value = pPacket.ReadByte();
                pConnection.Logger_WriteLine("0x400000 | {0}", value);
            }

            if (CheckFlag(updateFlag, 0x800000))
            {
                // Ambition/Charisma D:
                pConnection.CharData.Stats.Traits[(int)GW_CharacterStat.TraitVals.Charisma] = pPacket.ReadInt();
            }

            if (CheckFlag(updateFlag, 0x1000000))
            {
                pConnection.CharData.Stats.Traits[(int)GW_CharacterStat.TraitVals.Insight] = pPacket.ReadInt();
                didsomething = true;
            }

            if (CheckFlag(updateFlag, 0x2000000))
            {
                pConnection.CharData.Stats.Traits[(int)GW_CharacterStat.TraitVals.Willpower] = pPacket.ReadInt();
                didsomething = true;
            }

            if (CheckFlag(updateFlag, 0x4000000))
            {
                pConnection.CharData.Stats.Traits[(int)GW_CharacterStat.TraitVals.CraftDiligence] = pPacket.ReadInt();
                didsomething = true;
            }

            if (CheckFlag(updateFlag, 0x8000000))
            {
                pConnection.CharData.Stats.Traits[(int)GW_CharacterStat.TraitVals.Empathy] = pPacket.ReadInt();
                didsomething = true;
            }

            if (CheckFlag(updateFlag, 0x10000000))
            {
                pConnection.CharData.Stats.Traits[(int)GW_CharacterStat.TraitVals.Charm] = pPacket.ReadInt();
                didsomething = true;
            }

            if (CheckFlag(updateFlag, 0x20000000))
            {
                pPacket.ReadBytes(21);
            }

            if (CheckFlag(updateFlag, 0x40000000))
            {
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
            }

            if (CheckFlag(updateFlag, 0x80000000))
            {
                for (byte i = 0; i < 9; i++)
                {
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                }
            }

            if (CheckFlag(updateFlag, 0x100000000))
            {
                var value1 = pPacket.ReadByte();
                var value2 = pPacket.ReadByte();
                pConnection.Logger_WriteLine("0x100000000 | {0} | {1}", value1, value2);
            }

            if (CheckFlag(updateFlag, 0x200000000))
            {
                var value = pPacket.ReadInt();
                pConnection.Logger_WriteLine("0x200000000 | {0}", value);
            }

            if (didsomething)
            {
                pConnection.CharData.SaveCharacterInfo(pConnection);

                pConnection.SendTimeUpdate();
            }
        }
コード例 #20
0
ファイル: Session.cs プロジェクト: diamondo25/mapler.me
        internal bool BufferTCPPacket(TcpPacket pTCPPacket, bool pInbound)
        {
            if (pTCPPacket.Syn && pTCPPacket.Ack)
            {
                mInboundSequence = (uint)(pTCPPacket.SequenceNumber + 1); 
                return true;
            }
            if (pTCPPacket.PayloadData.Length == 0) return true;
            if (_mapleVersion == 0)
            {
                if (pTCPPacket.PayloadData.Length < 13) return false;
                byte[] tcpData = pTCPPacket.PayloadData;

                MaplePacket pr = new MaplePacket(tcpData);
                pr.ReadShort();
                _mapleVersion = pr.ReadUShort();
                var pos = pr.Position;
                {
                    var shrt = pr.ReadShort();
                    if (shrt < 0 || shrt > 0x0020)
                    {
                        return false;
                    }
                }
                pr.Reset(pos);
                _maplePatchLocation = pr.ReadString();
                byte[] localIV = pr.ReadBytes(4);
                byte[] remoteIV = pr.ReadBytes(4);
                _mapleLocale = pr.ReadByte();

                if (pr.Length > pr.Position || _mapleLocale > 0x12)
                {
                    return false;
                }

                pr.Dispose();
                pr = null;

                mOutboundStream = new PacketStream(localIV, _mapleLocale, _mapleVersion, !pInbound);
                mInboundStream = new PacketStream(remoteIV, _mapleLocale, (ushort)(0xFFFF - _mapleVersion), pInbound);
                mInboundSequence += (uint)tcpData.Length;

            }
            if (!pInbound) ProcessTCPPacket(pTCPPacket, ref mOutboundSequence, mOutboundBuffer, mOutboundStream, pInbound);
            else ProcessTCPPacket(pTCPPacket, ref mInboundSequence, mInboundBuffer, mInboundStream, pInbound);

            return true;
        }
コード例 #21
0
        public virtual void HandleTradeData(ClientConnection pConnection, MaplePacket pPacket)
        {
            byte type = pPacket.ReadByte();
            pPacket.ReadByte();
            if (type == 0x0A)
            {
                pPacket.ReadByte();
                pPacket.ReadShort();
                int merchid = pPacket.ReadInt();
                string merchname = pPacket.ReadString();
                pPacket.ReadByte();
                while (true)
                {
                    byte slot = pPacket.ReadByte();
                    if (slot == 255) break;

                    pPacket.ReadInt(); // Player ID
                    ParseAvatar(pPacket);
                    pPacket.ReadString(); // Player Name
                    pPacket.ReadShort(); // Job
                }

                pPacket.ReadShort();
                pPacket.ReadString(); // Owner name
                pPacket.ReadShort(); // Shop cash ID
                pPacket.ReadString(); // Shop name
                pPacket.ReadInt(); // ???
                pPacket.ReadByte(); // ???

                byte items = pPacket.ReadByte();

                using (InsertQueryBuilder itemsTable = new InsertQueryBuilder("items_trades"))
                {
                    for (int i = 0; i < items; i++)
                    {
                        short slot = pPacket.ReadShort(); // Slot?
                        pPacket.ReadShort();
                        pPacket.ReadInt(); // Price
                        Queries.SaveItem(pConnection, (ushort)0, slot, ItemBase.DecodeItemData(pConnection, pPacket), itemsTable, true);
                    }

                    MySQL_Connection.Instance.RunQuery("DELETE FROM items_trades"); // Clear table

                    itemsTable.RunQuery();
                }
            }
        }
        public override void Decode(MaplePacket pPacket)
        {
            base.Decode(pPacket);

            Petname = pPacket.ReadString(13);
            Level = pPacket.ReadByte();
            Closeness = pPacket.ReadShort();
            Fullness = pPacket.ReadByte();


            pPacket.Skip(8 + 2 + 2 + 4 + 2 + 1 + 4 + 4);
        }
コード例 #23
0
        public void DecodePQDone(ClientConnection pConnection, MaplePacket pPacket)
        {
            PartyQuestsDone = new Dictionary<ushort, long>();
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                ushort id = pPacket.ReadUShort();
#if LOCALE_EMS
                var date = pPacket.ReadUInt();

                long time = DecodeTimeFromInt(pConnection, date);
#else
                long time = pPacket.ReadLong();
#endif
                if (!PartyQuestsDone.ContainsKey(id))
                    PartyQuestsDone.Add(id, time);
                else
                    pConnection.Logger_WriteLine("Duplicate PQ (Done): {0}", id);
            }
        }
コード例 #24
0
ファイル: Guild.cs プロジェクト: diamondo25/mapler.me
        public void Decode(MaplePacket pPacket)
        {
            ID = pPacket.ReadInt();
            Name = pPacket.ReadString();

            for (byte i = 0; i < 5; i++)
                Ranks[i] = pPacket.ReadString();

            Players = pPacket.ReadByte();

            Members = new List<GuildMember>();
            for (byte i = 0; i < Players; i++)
            {
                var id = pPacket.ReadInt(); // Player ID

                Members.Add(new GuildMember() { CharacterID = id });
            }

            for (byte i = 0; i < Players; i++)
            {
                GuildMember tmp = Members[i];

                pPacket.ReadString(13); // Name
                pPacket.ReadInt(); // Job ID
                pPacket.ReadInt(); // Level OR -1
                tmp.Rank = (byte)pPacket.ReadInt(); // Guild Rank
                pPacket.ReadInt(); // Online
                pPacket.ReadInt(); // Alliance Rank
                tmp.Contribution = pPacket.ReadInt(); // Contribution
            }

            Capacity = (byte)pPacket.ReadInt();
            Background = pPacket.ReadShort();
            BackgroundColor = pPacket.ReadByte();
            Foreground = pPacket.ReadShort();
            ForegroundColor = pPacket.ReadByte();

            Notice = pPacket.ReadString();

            Points = pPacket.ReadInt();
            pPacket.ReadInt(); // Today's points
            AllianceID = pPacket.ReadInt();

            pPacket.ReadByte(); // Unk
            pPacket.ReadShort(); // Herp

            Skills = new List<GuildSkill>();
            var skills = pPacket.ReadShort(); // Buffs
            for (var i = 0; i < skills; i++)
            {
                GuildSkill gb = new GuildSkill()
                {
                    SkillID = pPacket.ReadInt(),
                    Level = pPacket.ReadShort(),
                    BoughtAt = pPacket.ReadLong(),
                    BoughtBy = pPacket.ReadString(),
                    Unknown = pPacket.ReadString()
                };

                Skills.Add(gb);
            }
        }
コード例 #25
0
 public void DecodePQ(ClientConnection pConnection, MaplePacket pPacket)
 {
     PartyQuestsRunning = new Dictionary<ushort, string>();
     for (int i = pPacket.ReadShort(); i > 0; i--)
     {
         ushort id = pPacket.ReadUShort();
         string value = pPacket.ReadString();
         if (!PartyQuestsRunning.ContainsKey(id))
             PartyQuestsRunning.Add(id, value);
         else
             pConnection.Logger_WriteLine("Duplicate PQ (Running): {0}", id);
     }
 }
コード例 #26
0
 private static short FlaggedValue(ClientConnection pConnection, int pItemID, uint pValue, uint pFlag, MaplePacket pPacket, short pTypeValue, bool pLogIfFound = false)
 {
     if (pValue.HasFlag(pFlag))
     {
         var val = pPacket.ReadShort();
         if (pLogIfFound)
             pConnection.Logger_WriteLine("Found flag {3} {0:X8}: {1} | ItemID: {2}", pFlag, val, pItemID, pTypeValue.GetType().Name);
         return val;
     }
     else
         return 0;
 }
コード例 #27
0
ファイル: CharacterData.cs プロジェクト: diamondo25/mapler.me
        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
        }
コード例 #28
0
        public override void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            base.Decode(pConnection, pPacket);

            Amount = pPacket.ReadShort();
            CraftName = pPacket.ReadString();
            Flags = pPacket.ReadShort();

            int itemtype = ItemID / 10000;
            if (itemtype == 233 || itemtype == 207 || itemtype == 287 || itemtype == 288 || itemtype == 289) // Stars, Bullets & Familiars
                UniqueID = pPacket.ReadLong();
        }
コード例 #29
0
        public override void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            base.Decode(pConnection, pPacket);


            List<string> flagsList = new List<string>();
            {
                {
                    uint flag = pPacket.ReadUInt();

                    this.Slots = FlaggedValue(pConnection, this.ItemID, flag, 0x01, pPacket, this.Slots);
                    this.Scrolls = FlaggedValue(pConnection, this.ItemID, flag, 0x02, pPacket, this.Scrolls);
                    this.Str = FlaggedValue(pConnection, this.ItemID, flag, 0x04, pPacket, this.Str);
                    this.Dex = FlaggedValue(pConnection, this.ItemID, flag, 0x08, pPacket, this.Dex);
                    this.Int = FlaggedValue(pConnection, this.ItemID, flag, 0x10, pPacket, this.Int);
                    this.Luk = FlaggedValue(pConnection, this.ItemID, flag, 0x20, pPacket, this.Luk);
                    this.HP = FlaggedValue(pConnection, this.ItemID, flag, 0x40, pPacket, this.HP);
                    this.MP = FlaggedValue(pConnection, this.ItemID, flag, 0x80, pPacket, this.MP);
                    this.Watk = FlaggedValue(pConnection, this.ItemID, flag, 0x100, pPacket, this.Watk);
                    this.Matk = FlaggedValue(pConnection, this.ItemID, flag, 0x200, pPacket, this.Matk);
                    this.Wdef = FlaggedValue(pConnection, this.ItemID, flag, 0x400, pPacket, this.Wdef);
                    this.Mdef = FlaggedValue(pConnection, this.ItemID, flag, 0x800, pPacket, this.Mdef);
                    this.Acc = FlaggedValue(pConnection, this.ItemID, flag, 0x1000, pPacket, this.Acc);
                    this.Avo = FlaggedValue(pConnection, this.ItemID, flag, 0x2000, pPacket, this.Avo);
                    this.Hands = FlaggedValue(pConnection, this.ItemID, flag, 0x4000, pPacket, this.Hands);
                    this.Speed = FlaggedValue(pConnection, this.ItemID, flag, 0x8000, pPacket, this.Speed);
                    this.Jump = FlaggedValue(pConnection, this.ItemID, flag, 0x10000, pPacket, this.Jump);
                    this.Flags = FlaggedValue(pConnection, this.ItemID, flag, 0x20000, pPacket, this.Flags);

                    this.IncreasesSkills = FlaggedValue(pConnection, this.ItemID, flag, 0x40000, pPacket, this.IncreasesSkills);

                    this.ItemLevel = FlaggedValue(pConnection, this.ItemID, flag, 0x80000, pPacket, this.ItemLevel);
                    this.ItemEXP = FlaggedValue(pConnection, this.ItemID, flag, 0x100000, pPacket, this.ItemEXP);


                    this.Durability = FlaggedValue(pConnection, this.ItemID, flag, 0x200000, pPacket, this.Durability);
                    this.ViciousHammer = FlaggedValue(pConnection, this.ItemID, flag, 0x400000, pPacket, this.ViciousHammer);

                    this.BattleModeDamage = FlaggedValue(pConnection, this.ItemID, flag, 0x800000, pPacket, this.BattleModeDamage);

                    FlaggedValue(pConnection, this.ItemID, flag, 0x1000000, pPacket, (byte)0, true); // Item level changer?
                    FlaggedValue(pConnection, this.ItemID, flag, 0x2000000, pPacket, (short)0, true); // Enhancement buff?
                    FlaggedValue(pConnection, this.ItemID, flag, 0x4000000, pPacket, (int)0, true);
                    FlaggedValue(pConnection, this.ItemID, flag, 0x8000000, pPacket, (byte)0, true); // Required level changer?!
                    FlaggedValue(pConnection, this.ItemID, flag, 0x10000000, pPacket, (byte)0, true); // Yggdrasil Wisdom?
                    FlaggedValue(pConnection, this.ItemID, flag, 0x20000000, pPacket, (byte)0, true); // Final Strike?
                    FlaggedValue(pConnection, this.ItemID, flag, 0x40000000, pPacket, (byte)0, true); // Boss Damage %?
                    FlaggedValue(pConnection, this.ItemID, flag, 0x80000000, pPacket, (byte)0, true); // Ignore Damage %?
                }

                {
                    uint flag = pPacket.ReadUInt();
                    FlaggedValue(pConnection, this.ItemID, flag, 0x01, pPacket, (byte)0, true); // Total damage?
                    FlaggedValue(pConnection, this.ItemID, flag, 0x02, pPacket, (byte)0, true); // All stats?
                    this.MaxScissors = FlaggedValue(pConnection, this.ItemID, flag, 0x04, pPacket, this.MaxScissors);
                    FlaggedValue(pConnection, this.ItemID, flag, 0x08, pPacket, (long)0, true);
                    FlaggedValue(pConnection, this.ItemID, flag, 0x10, pPacket, (int)0, true);
                }
            }

            this.Name = pPacket.ReadString();

            this.StatusFlags = pPacket.ReadUShort(); // Actually 2 bytes

            this.Potential1 = pPacket.ReadUShort();
            this.Potential2 = pPacket.ReadUShort();
            this.Potential3 = pPacket.ReadUShort();

            this.Potential4 = pPacket.ReadUShort();
            this.Potential5 = pPacket.ReadUShort();
            this.Potential6 = pPacket.ReadUShort();

            this.DisplayID = pPacket.ReadUShort();

#if LOCALE_GMS
            this.SocketState = pPacket.ReadUShort();
            this.Nebulite1 = pPacket.ReadShort();
            this.Nebulite2 = pPacket.ReadShort();
            this.Nebulite3 = pPacket.ReadShort();
#else
            pPacket.ReadShort();
#endif

            if (CashID == 0)
                this.UniqueID = pPacket.ReadLong();
            else
                this.UniqueID = 0;

            pPacket.ReadLong(); // Some weird expiration time


            pPacket.ReadInt(); // always -1?

#if (LOCALE_EMS || LOCALE_GMS)
            // Prolly RED patch related
            pPacket.ReadLong();
            pPacket.ReadLong(); // This is 94354848000000000; a default date for no expiration. 
            pPacket.ReadInt();
            for (int i = 0; i < 3; i++)
                pPacket.ReadInt();

#endif

            // Fix setflags
            if ((this.Flags & 0x80) == 0x80 && this.Name != "")
            {
                flagsList.Add("crafted");
            }

            this.SetFlags = string.Join(",", flagsList);
        }
コード例 #30
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            if (pPacket.ReadBool())
            {
                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    Skill skill = new Skill();
                    skill.ID = pPacket.ReadInt();
                    skill.Level = pPacket.ReadInt();
                    skill.Expiration = pPacket.ReadLong();

                    if (GameHelper.is_skill_need_master_level(skill.ID))
                        skill.MasterLevel = pPacket.ReadInt();
                    else
                        skill.MasterLevel = -1;

                    if (SkillList.ContainsKey(skill.ID)) // NEXON
                        pConnection.Logger_WriteLine("Found duplicate skill {0}", skill.ID);
                    else
                        SkillList.Add(skill.ID, skill);
                }

                // Link skills
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadShort();
                }
            }
            else
            {
                pConnection.Logger_WriteLine("Character has 'new' skilllist!");
                // 0.0
                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                }

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

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

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

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

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

            }

            short amnt = pPacket.ReadShort();

            for (short i = 0; i < amnt; i++)
            {
                Cooldowns.Add(pPacket.ReadInt(), pPacket.ReadInt());
            }
        }