Beispiel #1
0
        public bool GetCharacter(Int32 aid, byte nIndex, CharacterInfo charInfo)
        {
            lock (_sqlConnection)
            {
                using (var command = new MySqlCommand("SELECT * FROM `character` WHERE AID=@aid AND CharNum=@index", _sqlConnection))
                {
                    command.Parameters.AddWithValue("@aid", aid);
                    command.Parameters.AddWithValue("@index", nIndex);

                    using (var reader = command.ExecuteReader())
                    {
                        if (reader == null || !reader.Read())
                            return false;

                        charInfo.CharacterId = Convert.ToInt32(reader["CID"]);
                        charInfo.ClanId = 0;
                        charInfo.Name = Convert.ToString(reader["Name"]);
                        charInfo.Level = Convert.ToByte(reader["Level"]);
                        charInfo.Sex = Convert.ToByte(reader["Sex"]);
                        charInfo.Hair = Convert.ToByte(reader["Hair"]);
                        charInfo.Face = Convert.ToByte(reader["Face"]);
                        charInfo.Xp = Convert.ToUInt32(reader["XP"]);
                        charInfo.Bp = Convert.ToInt32(reader["BP"]);
                        charInfo.BonusRate = 0.0f;
                        charInfo.Prize = 0;
                        charInfo.Fr = 0;
                        charInfo.Er = 0;
                        charInfo.Cr = 0;
                        charInfo.Wr = 0;
                        charInfo.SafeFalls = 0;
                        charInfo.Kills = Convert.ToInt32(reader["KillCount"]);
                        charInfo.Deaths = Convert.ToInt32(reader["DeathCount"]);
                        reader.Close();

                        var items = new ArrayList();

                        Execute("SELECT head_slot,chest_slot,hands_slot,legs_slot,Feet_slot,fingerl_slot,fingerr_slot,melee_slot,primary_slot,secondary_slot,custom1_slot,custom2_slot,avatar_slot,community1_slot,community2_slot,longbuff1_slot,longbuff2_slot FROM `character` WHERE CID=" + charInfo.CharacterId, items);
                        for (int i = 0; i < 17; i++)
                        {
                            charInfo.EquippedItems[i] = new Item();
                            charInfo.EquippedItems[i].ItemCid = Convert.ToInt32(items[i]);
                            charInfo.EquippedItems[i].RentHour = 525600;
                        }

                        var clanInfo = new ArrayList();
                        Execute("SELECT CLID,Grade,ContPoint FROM clanmember WHERE CID=" + charInfo.CharacterId, clanInfo);
                        if (clanInfo.Count > 0)
                        {
                            charInfo.ClanId = (Int32)clanInfo[0] < 0 ? 0 : (Int32)clanInfo[0];
                            charInfo.ClanGrade = (ClanGrade)Convert.ToInt32(clanInfo[1]);
                            charInfo.ClanPoint = Convert.ToInt16(clanInfo[2]);

                            charInfo.ClanName = Convert.ToString(GetQueryScalar("SELECT Name FROM clan WHERE CLID=" + charInfo.ClanId));
                        }

                        command.CommandText = "SELECT ItemID,CIID,RentHourPeriod,quantity FROM characteritem WHERE CID=" + charInfo.CharacterId;
                        reader.Close();
                        using (var dataReader = command.ExecuteReader())
                        {
                            if (dataReader != null)
                            {
                                while (dataReader.Read())
                                {
                                    Item nItem = new Item();
                                    nItem.ItemId = Convert.ToInt32(dataReader["itemid"]);
                                    nItem.ItemCid = Convert.ToInt32(dataReader["CIID"]);
                                    nItem.RentHour =
                                        Convert.ToInt32(dataReader.IsDBNull(2) ? 0 : dataReader["RentHourPeriod"]);
                                    nItem.Quantity = Convert.ToInt32(dataReader.IsDBNull(3) ? 0 : dataReader["quantity"]);
                                    charInfo.Items.Add(nItem);
                                }
                            }
                        }
                        for (var i = 0; i < 12; i++)
                        {
                            var item = charInfo.Items.Find(ii => ii.ItemCid == charInfo.EquippedItems[i].ItemCid);
                            charInfo.EquippedItems[i].ItemId = item == null ? 0 : item.ItemId;
                        }
                        return true;
                    }
                }
            }
        }
Beispiel #2
0
        public void Write(CharacterInfo charInfo, bool bObfuscation = true)
        {
            Write(1, 374);
            Write(charInfo.Name, 32);
            Write(charInfo.ClanName, 16);
            Write((Int32)charInfo.ClanGrade);
            Write(charInfo.ClanPoint);
            Write(charInfo.CharNum);
            Write(charInfo.Level);
            Write(charInfo.Sex);
            Write(charInfo.Hair);
            Write(charInfo.Face);
            Write(charInfo.Xp);
            Write(charInfo.Bp);
            Write(charInfo.BonusRate);
            Write(charInfo.Prize);
            Write(charInfo.Hp);
            Write(charInfo.Ap);
            Write(charInfo.MaxWeight);
            Write(charInfo.SafeFalls);
            Write(charInfo.Fr);
            Write(charInfo.Cr);
            Write(charInfo.Er);
            Write(charInfo.Wr);
            for (int i = 0; i < 17; i++)
                Write(charInfo.EquippedItems[i].ItemId);
            Write((Int32)charInfo.UGrade);
            Write(charInfo.ClanId);
            if (bObfuscation)
            {
                byte[] sequence = { 0xFF, 0xFF, 0xFF, 0xFF };
                Write(sequence);
                WriteSkip(204);
            }
            else
            {
                Write((int)0);

                //Since faggots will be faggots.
                //This is acctually a list: UInt64[17] CIID, UInt32[17] Quantity
                byte[] obfuscation = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x79, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4B, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4A, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                Log.Write(obfuscation.Length.ToString());
                Write(obfuscation);
            }
        }