示例#1
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            pPacket.Skip(8); // Flag

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

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

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

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

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


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

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

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

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

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

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

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


            // Unknown stuff here

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

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

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


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

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

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


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

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

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

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

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


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


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


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

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

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

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


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

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


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

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


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


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

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

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

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

                    MarriedWith = ring.FriendName;
                }
            }


            Inventory.DecodeTeleportRocks(pPacket);

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

            pPacket.ReadInt(); // -1?

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

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

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

            Quests.DecodePQ(pConnection, pPacket);

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

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

            Quests.DecodePQDone(pConnection, pPacket);

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

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

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

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

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

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

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

                pPacket.ReadByte();
            }
#endif

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

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

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

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

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

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


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


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

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

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

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

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

#if LOCALE_EMS
            // No farm info

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

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

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

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

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

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

            pPacket.ReadByte();

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

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

                pPacket.Skip(32);
            }

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

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

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

            // Removed in V.141
            //pPacket.ReadInt(); // I DONT EVEN D:
#endif
        }
示例#2
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
        }
示例#3
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());
            }
        }
示例#4
0
        public void Save(byte pWorldID)
        {
            pWorldID = GameHelper.GetAllianceWorldID(pWorldID);

            using (InsertQueryBuilder guildTable = new InsertQueryBuilder("guilds"))
            {
                guildTable.OnDuplicateUpdate = true;
                guildTable.AddColumn("id", false);
                guildTable.AddColumn("world_id", true);
                guildTable.AddColumn("name", true);
                guildTable.AddColumn("notice", true);
                guildTable.AddColumn("rank1", true);
                guildTable.AddColumn("rank2", true);
                guildTable.AddColumn("rank3", true);
                guildTable.AddColumn("rank4", true);
                guildTable.AddColumn("rank5", true);
                guildTable.AddColumn("capacity", true);
                guildTable.AddColumn("emblem_bg", true);
                guildTable.AddColumn("emblem_bg_color", true);
                guildTable.AddColumn("emblem_fg", true);
                guildTable.AddColumn("emblem_fg_color", true);
                guildTable.AddColumn("points", true);
                guildTable.AddColumn("alliance_id", true);

                guildTable.AddRow(
                    ID, pWorldID, Name,
                    Notice,
                    Ranks[0],
                    Ranks[1],
                    Ranks[2],
                    Ranks[3] == "" ? null : Ranks[3],
                    Ranks[4] == "" ? null : Ranks[4],
                    Capacity,
                    Background,
                    BackgroundColor,
                    Foreground,
                    ForegroundColor,
                    Points,
                    AllianceID
                    );

                guildTable.RunQuery();
            }

            // Delete members first

            MySQL_Connection.Instance.RunQuery("DELETE FROM guild_members WHERE guild_id = " + ID);

            using (InsertQueryBuilder guildMembersTable = new InsertQueryBuilder("guild_members"))
            {
                guildMembersTable.OnDuplicateUpdate = true;
                guildMembersTable.AddColumn("guild_id", true);
                guildMembersTable.AddColumn("world_id", true);
                guildMembersTable.AddColumn("character_id", false); // Switching guild huh?
                guildMembersTable.AddColumn("rank", true);
                guildMembersTable.AddColumn("contribution", true);

                foreach (var member in Members)
                {
                    guildMembersTable.AddRow(
                        ID,
                        pWorldID,
                        member.CharacterID,
                        member.Rank,
                        member.Contribution
                        );
                }

                if (guildMembersTable.RowCount > 0)
                {
                    MySQL_Connection.Instance.RunQuery(guildMembersTable.ToString());
                }
            }

            using (InsertQueryBuilder guildSkillsTable = new InsertQueryBuilder("guild_skills"))
            {
                guildSkillsTable.OnDuplicateUpdate = true;
                guildSkillsTable.AddColumn("guild_id", false);
                guildSkillsTable.AddColumn("world_id", true);
                guildSkillsTable.AddColumn("skill_id", false);
                guildSkillsTable.AddColumn("level", true);
                guildSkillsTable.AddColumn("bought_by", true);
                guildSkillsTable.AddColumn("bought_at", true);
                guildSkillsTable.AddColumn("unk", true);

                foreach (var skill in Skills)
                {
                    guildSkillsTable.AddRow(
                        ID,
                        pWorldID,
                        skill.SkillID,
                        skill.Level,
                        skill.BoughtBy,
                        skill.BoughtAt,
                        skill.Unknown
                        );
                }

                if (guildSkillsTable.RowCount > 0)
                {
                    MySQL_Connection.Instance.RunQuery(guildSkillsTable.ToString());
                }
            }
        }
        public override 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, 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();
            }
            // EMS Weird stuff
            if (CheckFlag(updateFlag, 0x80000))
            {
                var value = pPacket.ReadLong();
                pConnection.Logger_WriteLine("0x80000 | {0}", value);
            }
            if (CheckFlag(updateFlag, 0x100000))
            {
                var value = pPacket.ReadByte();
                pConnection.Logger_WriteLine("0x100000 | {0}", value);
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                pConnection.SendTimeUpdate();
            }
        }