Exemple #1
0
        public static void LauncherValidate(MartialClient c, InPacket p)
        {
            byte pinLength = p.ReadByte();
            byte uNameLength = p.ReadByte();
            byte passWLength = p.ReadByte();
            p.ReadByte();
            string pin = MiscFunctions.obscureString(p.ReadString(4));
            string uN = MiscFunctions.obscureString(p.ReadString(16));
            string pW = MiscFunctions.obscureString(p.ReadString(12));

            Account account = new Account();
            if(account.Load(uN, pW, pin) != Account.AccountLoadErrors.Success)
            {
                c.WriteRawPacket(Constants.accDoesntExist);
                Logger.WriteLog(Logger.LogTypes.HEmi, "Authorization error for [{0} | {1} | {2}]", uN, pW, pin);
                c.Close();
                return;
            }
            Logger.WriteLog(Logger.LogTypes.HEmi, "User passed authorization [{0} | {1} | {2}]", uN, pW, pin);
            account.mClient = c;
            c.setAccount(account);
            account.LoadCharacters();

            if(c.getAccount().characters.Count() > 0)
            {
                c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), false).Concat(Constants.emptyAccount).ToArray());
            }
            c.WriteRawPacket(Constants.emptyAccount);
            c.WriteRawPacket(LoginPacketCreator.initAccount(c.getAccount()));
        }
Exemple #2
0
 public void setAccount(Account account)
 {
     this.account = account;
 }
Exemple #3
0
        public static byte[] initCharacters(Account acc, bool backSpawn = false)
        {
            OutPacket all = new OutPacket((acc.characters.Count() * 653) + 8 + 3);
            all.WriteInt((acc.characters.Count() * 653) + 8 + 3);
            all.WriteShort(0x03);
            all.WriteShort((!backSpawn) ? ((byte)0x04) : ((byte)0x01));
            all.WriteBytes(new byte[] { (byte)0x01, (byte)0x01, (byte)0x01 });

            int multipier_keeper = 0x01;
            Boolean multiplied = false;

            foreach(Character chara in acc.characters.Values) {
                all.WriteBytes(CharacterPackets.initCharPacket(chara));

                if(multiplied)
                    multipier_keeper = (multipier_keeper * 2) + 1;
                if(!multiplied)
                    multiplied = true;
            }

            all.Position = 10;
            all.WriteByte((byte)multipier_keeper);
            return all.ToArray();
        }
Exemple #4
0
 public static byte[] initAccount(Account acc)
 {
     OutPacket op = new OutPacket(52);
     op.WriteInt(52);
     op.WriteShort(3);
     op.WriteShort(5);
     op.WritePaddedString(acc.name, 24);
     op.WriteInt(109);
     op.WriteInt(acc.MHPoints);
     op.WriteLong();
     op.WriteInt(acc.characters != null ? acc.characters.Count : 0);
     return op.ToArray();
 }
Exemple #5
0
        public int Load(Account acc)
        {
            using(var con = new MySqlConnection(MasterServer.Instance.SqlConnection.mConnectionString))
            using(var cmd = con.CreateCommand())
            {
                con.Open();
                cmd.CommandText = "SELECT * FROM chars WHERE charID=" + cID;
                using(var reader = cmd.ExecuteReader())
                {
                    reader.Read();

                    if(!reader.HasRows)
                    {
                        return 0;
                    }
                    else
                    {
                        name = reader.GetString("charName");
                        cClass = reader.GetByte("charClass");
                        deleteState = reader.GetBoolean("removeState");
                        invPages = reader.GetByte("invPages");
                        face = reader.GetByte("face");
                        effect = reader.GetByte("effect");
                        faction = reader.GetByte("faction");
                        level = reader.GetByte("level");
                        curHP = reader.GetInt32("curHP");
                        curMP = reader.GetInt16("curMP");
                        curSP = reader.GetInt16("curSP");
                        coin = reader.GetInt64("coin");
                        fame = reader.GetInt32("fame");
                        setPosition(new float[] { reader.GetFloat("locX"), reader.GetFloat("locY") });
                        map = reader.GetInt16("map");
                        inte = reader.GetInt16("Inte");
                        agi = reader.GetInt16("Agi");
                        vit = reader.GetInt16("Vit");
                        str = reader.GetInt16("Str");
                        dex = reader.GetInt16("Dex");
                        statPoints = reader.GetInt16("statPointz");
                        skillPoints = reader.GetInt16("skillPointz");
                        karmaMessagingTimes = reader.GetInt16("karmaMessagingTimes");
                        gmShoutMessagingTimes = reader.GetInt16("gmShoutMessagingTimes");
                    }
                }
            }
            return 1;
        }