Exemple #1
0
        public static void HandleCharacterSelection(MapleClient client, InPacket iPacket)
        {
            int    characterID  = iPacket.ReadInt();
            string macAddresses = iPacket.ReadMapleString(); // TODO: Do something with these.

            LoginHandler.MigrateClient(client, characterID);
        }
Exemple #2
0
        public static void HandleWorldSelect(MapleClient client, InPacket iPacket)
        {
            iPacket.Skip(1);
            client.World   = iPacket.ReadByte();
            client.Channel = iPacket.ReadByte();

            byte characterCount = (byte)(long)Database.Scalar("SELECT COUNT(*) FROM `characters` WHERE `account_id` = @account_id", new MySqlParameter("@account_id", client.Account.ID));

            using (OutPacket oPacket = new OutPacket(SendOps.SelectWorldResult))
            {
                oPacket
                .WriteBool(false)
                .WriteByte(characterCount);

                if (characterCount > 0)
                {
                    using (DatabaseQuery query = Database.Query("SELECT * FROM `characters` WHERE `account_id` = @account_id AND `world_id` = @world_id", new MySqlParameter("@account_id", client.Account.ID), new MySqlParameter("world_id", client.World)))
                    {
                        while (query.NextRow())
                        {
                            LoginHandler.AddCharacterEntry(oPacket, query);
                        }
                    }
                }

                oPacket
                .WriteByte(2)
                .WriteInt(3);     // TODO: Account specific character creation slots. For now, use default 3.

                client.Send(oPacket);
            }
        }
Exemple #3
0
        // TODO: Handle different scenarios (ban, quiet ban, etcetera).
        public static void HandleLoginPassword(MapleClient client, InPacket iPacket)
        {
            string username = iPacket.ReadMapleString();
            string password = iPacket.ReadMapleString();

            Account account;

            using (DatabaseQuery query = Database.Query("SELECT * FROM `accounts` WHERE `username` = @username", new MySqlParameter("username", username)))
            {
                if (!query.NextRow())
                {
                    if (MasterServer.Instance.Login.AutoRegister && username == client.LastUsername && password == client.LastPassword)
                    {
                        // TODO: Auto register.
                    }
                    else
                    {
                        LoginHandler.SendLoginResult(client, LoginResult.NotRegistered);
                    }

                    return;
                }

                account = new Account(query);
            }

            if (SHACryptograph.Encrypt(SHAMode.SHA512, password + account.Salt) != account.Password)
            {
                LoginHandler.SendLoginResult(client, LoginResult.IncorrectPassword);
            }
            else
            {
                client.Account = account;

                LoginHandler.SendLoginResult(client, LoginResult.Valid);
            }
        }
Exemple #4
0
        public static void HandleCharacterCreation(MapleClient client, InPacket iPacket)
        {
            string name      = iPacket.ReadMapleString();
            int    jobType   = iPacket.ReadInt();
            int    face      = iPacket.ReadInt();
            int    hair      = iPacket.ReadInt();
            int    hairColor = iPacket.ReadInt();
            byte   skin      = (byte)iPacket.ReadInt();
            int    topID     = iPacket.ReadInt();
            int    bottomID  = iPacket.ReadInt();
            int    shoesID   = iPacket.ReadInt();
            int    weaponID  = iPacket.ReadInt();
            Gender gender    = (Gender)iPacket.ReadByte();

            bool error = false;

            // TODO: Validate name, beauty and equipment before creating the character.

            int id = Database.InsertAndReturnIdentifier("INSERT INTO `characters` (account_id, world_id, name, gender, skin, face, hair) " +
                                                        "VALUES (@account_id, @world_id, @name, @gender, @skin, @face, @hair)",
                                                        new MySqlParameter("account_id", client.Account.ID),
                                                        new MySqlParameter("world_id", client.World),
                                                        new MySqlParameter("name", name),
                                                        new MySqlParameter("gender", gender),
                                                        new MySqlParameter("skin", skin),
                                                        new MySqlParameter("face", face),
                                                        new MySqlParameter("hair", hair));

            // TODO: Validate the default equipment statistics. I'm pretty sure some of them are untradable.

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, weapon_defense) " +
                             "VALUES (@character_id, 0, -5, @maple_id, 3)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", topID));

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, weapon_defense) " +
                             "VALUES (@character_id, 0, -6, @maple_id, 2)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", bottomID));

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, slots, weapon_defense) " +
                             "VALUES (@character_id, 0, -7, @maple_id, 5, 3)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", shoesID));

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, slots, weapon_attack) " +
                             "VALUES (@character_id, 0, -11, @maple_id, 7, 17)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", weaponID));

            // TODO: Add beginner's guide (based on job).

            using (DatabaseQuery query = Database.Query("SELECT * FROM characters WHERE `character_id` = @character_id", new MySqlParameter("character_id", id)))
            {
                query.NextRow();

                using (OutPacket oPacket = new OutPacket(SendOps.CreateNewCharacterResult))
                {
                    oPacket.WriteBool(error);

                    LoginHandler.AddCharacterEntry(oPacket, query);

                    client.Send(oPacket);
                }
            }
        }