private void saveCodesetgctToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (sss.IgnoredMetadata)
            {
                MessageBox.Show(
                    "Warning: extra data was found after the GCT footer (probably code titles placed there by BrawlBox) and will be discarded if you continue to save.");
            }

            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.Filter          = "Ocarina codes (*.gct)|*.gct";
                dialog.OverwritePrompt = true;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    using (FileStream fs = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write))
                    {
                        foreach (byte[] b in new byte[][]
                        {
                            sss.DataBefore, ByteUtilities.StringToByteArray(ToCode()), sss.DataAfter
                        })
                        {
                            fs.Write(b, 0, b.Length);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public Account LoadAccount(string username)
        {
            string       SqlQuery   = "SELECT * FROM `accounts` WHERE `username` = ?username";
            MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);

            SqlCommand.Parameters.AddWithValue("?username", username);
            MySqlDataReader AccountReader = SqlCommand.ExecuteReader();

            Account acc = new Account();

            if (AccountReader.HasRows)
            {
                while (AccountReader.Read())
                {
                    acc.AccountId     = AccountReader.GetInt32(0);
                    acc.Username      = AccountReader.GetString(1);
                    acc.Password      = AccountReader.GetString(2);
                    acc.Email         = AccountReader.GetString(3);
                    acc.AccessLevel   = (byte)AccountReader.GetInt32(4);
                    acc.Membership    = (byte)AccountReader.GetInt32(5);
                    acc.isGM          = AccountReader.GetBoolean(6);
                    acc.LastOnlineUtc = AccountReader.GetInt64(7);
                    acc.Coins         = (int)AccountReader.GetInt32(8);
                    acc.Ip            = AccountReader.GetString(9);
                    acc.UiSettings    = ByteUtilities.StringToByteArray(AccountReader.GetString(10));
                }
            }
            AccountReader.Close();
            return((acc.Username == "") ? null : acc);
        }
Beispiel #3
0
        public void SendPlayerList(IConnection connection)
        {
            new SpSendCharacterList(connection.GameAccount).Send(connection);
            if (connection.GameAccount.UiSettings != null)
            {
                new SpUISettings(ByteUtilities.StringToByteArray(connection.GameAccount.UiSettings)).Send(connection);
            }


            //Premium Info
            //new SendPacket("6FDC0200080008001800B1010000232014550000000018000000B2010000FFFFFF7F00000000").Send(connection);
            new SpAccountItems(connection.GameAccount).Send(connection);
        }
        private void init(string[] s)
        {
            Regex r = new Regex(@"(\* )?[A-Fa-f0-9]{8} [A-Fa-f0-9]{8}");
            IEnumerable <string> matching_lines =
                from line in s
                where r.IsMatch(line)
                select line;

            byte[] core = ByteUtilities.StringToByteArray(string.Join("\n", matching_lines));
            byte[] data = new byte[core.Length + 16];
            Array.ConstrainedCopy(gctheader, 0, data, 0, 8);
            Array.ConstrainedCopy(core, 0, data, 8, core.Length);
            Array.ConstrainedCopy(gctfooter, 0, data, data.Length - 8, 8);
            init(data);
        }
        private void init(byte[] data)
        {
            OtherCodesIgnoredInSameFile = 0;
            IgnoredMetadata             = false;
            int index = -1;

            for (int line = 0; line < data.Length; line += 8)
            {
                if (ByteUtilities.ByteArrayEquals(data, line, SSS_HEADER, 0, SSS_HEADER.Length))
                {
                    if (index != -1)
                    {
                        OtherCodesIgnoredInSameFile++;
                    }

                    index = line;
                }
            }

            if (index < 0)
            {
                if (data.Length > 0)
                {
                    MessageBox.Show("No custom SSS code found. A default code will be used.");
                }

                DataBefore = gctheader.ToArray();
                sss1       = ByteUtilities.StringToByteArray(
                    "00010203 04050709 080A0B0C 0D0E0F10 11141516 1A191217 0618131D 1E1B1C");
                sss2 = ByteUtilities.StringToByteArray("1F202122 23242526 2728");
                sss3 = ByteUtilities.StringToByteArray(
                    "01010202 03030404 05050606 07070808 0909330A 0B0B0C0C 0D0D0E0E 130F1410 " +
                    "15111612 17131814 19151C16 1D171E18 1F19201A 211B221C 231D241E 251F2932 " +
                    "2A332B34 2C352D36 2F373038 3139323A 2E3BFFFF");
                DataAfter = data.Skip(gctheader.Length).ToArray();
            }
            else
            {
                int start = index;
                DataBefore = new byte[start];
                Array.ConstrainedCopy(data, 0, DataBefore, 0, start);

                index += 14 * 8;
                byte sss1_count = data[index - 1];
                sss1 = new byte[sss1_count];
                Array.ConstrainedCopy(data, index, sss1, 0, sss1_count);

                index += sss1_count;
                while (index % 8 != 0)
                {
                    index++;
                }

                index += 2 * 8;
                byte sss2_count = data[index - 1];
                sss2 = new byte[sss2_count];
                Array.ConstrainedCopy(data, index, sss2, 0, sss2_count);

                index += sss2_count;
                while (index % 8 != 0)
                {
                    index++;
                }

                index += 1 * 8;
                byte sss3_count = data[index - 1];
                sss3 = new byte[sss3_count];
                Array.ConstrainedCopy(data, index, sss3, 0, sss3_count);

                index += sss3_count;
                while (index % 8 != 0)
                {
                    index++;
                }

                DataAfter = new byte[data.Length - index];
                Array.ConstrainedCopy(data, index, DataAfter, 0, data.Length - index);
            }

            bool footer_found = false;

            for (int i = 0; i < DataAfter.Length; i += 8)
            {
                if (footer_found)
                {
                    IgnoredMetadata = true;
                    DataAfter       = DataAfter.Take(i).ToArray();
                    break;
                }

                if (ByteUtilities.ByteArrayEquals(DataAfter, i, gctfooter, 0, 8))
                {
                    footer_found = true;
                }
            }
        }