Beispiel #1
0
        public static OutPacket ServerList(int[] channelUserLogged)
        {
            using (var packet = new OutPacket(SendOpcodes.Serverlist))
            {
                packet.WriteByte(0);                                //serverid
                packet.WriteMapleString(ServerSettings.ServerName);
                packet.WriteByte(0x03);                             //0: 正常 1: 火爆 2: 热 3: 新开
                packet.WriteMapleString(ServerSettings.ServerName); //eventmsg
                packet.WriteByte(0x64);
                packet.WriteByte(0x00);
                packet.WriteByte(0x64);
                packet.WriteByte(0x00);

                packet.WriteByte(ServerSettings.ChannelCount);
                packet.WriteInt(500);

                for (var i = 0; i < ServerSettings.ChannelCount; i++)
                {
                    var load = channelUserLogged[i];
                    packet.WriteMapleString(ServerSettings.ServerName + "-" + (i + 1));
                    packet.WriteInt(load);
                    packet.WriteByte(0x00); //serverid
                    packet.WriteShort((short)i);
                }
                packet.WriteShort(0);

                return(packet);
            }
        }
Beispiel #2
0
 public static OutPacket GenderChanged(string username, string accountId)
 {
     using (var packet = new OutPacket(SendOpcodes.GenderSet))
     {
         packet.WriteByte(0x00);
         packet.WriteMapleString(username);
         packet.WriteMapleString(accountId);
         return(packet);
     }
 }
Beispiel #3
0
        public static void OnCreateNewCharacter(MapleClient c, InPacket p)
        {
            string name = p.ReadMapleString();

            if (Database.Instance.NameAvailable(name))
            {
                Character character = new Character(name);
                character.AccountId = c.Account.AccountId;
                character.CharId    = Database.Instance.GetNewCharacterId();
                character.Level     = 1;

                character.HP    = 50;
                character.MaxHP = 50;
                character.MP    = 5;
                character.MaxMP = 5;

                character.Face      = p.ReadInt();
                character.Hair      = p.ReadInt() + p.ReadInt();
                character.SkinColor = (byte)p.ReadInt();

                int top    = p.ReadInt();
                int bottom = p.ReadInt();
                int shoes  = p.ReadInt();
                int weapon = p.ReadInt();

                character.Inventory[InventorySlot.Equipped].Items.Add(-5, new Item(top));
                character.Inventory[InventorySlot.Equipped].Items.Add(-6, new Item(bottom));
                character.Inventory[InventorySlot.Equipped].Items.Add(-7, new Item(shoes));
                character.Inventory[InventorySlot.Equipped].Items.Add(-11, new Item(weapon));

                character.Str = p.ReadByte();
                character.Dex = p.ReadByte();
                character.Int = p.ReadByte();
                character.Luk = p.ReadByte();

                c.Characters.Add(character);
                Database.Instance.Save <Character>(Database.Characters, character);

                using (OutPacket packet = new OutPacket(SendOps.CreateNewCharacterResult))
                {
                    packet.WriteByte();

                    PacketCreator.Helper.AddCharacterData(packet, character);
                    PacketCreator.Helper.AddCharaterLook(packet, character);
                    packet.WriteBool(false); //rank

                    packet.WriteZero(24);
                    c.Send(packet);
                }
            }
            else
            {
                using (OutPacket packet = new OutPacket(SendOps.CheckDuplicatedIDResult))
                {
                    packet.WriteMapleString(name);
                    packet.WriteBool(true);
                    c.Send(packet);
                }
            }
        }
Beispiel #4
0
 public static OutPacket GenderNeeded(string username)
 {
     using (var packet = new OutPacket(SendOpcodes.ChooseGender))
     {
         packet.WriteMapleString(username);
         return(packet);
     }
 }
Beispiel #5
0
 public static OutPacket CharNameResponse(string name, bool nameUsed)
 {
     using (var packet = new OutPacket(SendOpcodes.CharNameResponse))
     {
         packet.WriteMapleString(name);
         packet.WriteBool(nameUsed);
         return(packet);
     }
 }
Beispiel #6
0
 public static OutPacket AuthSuccess(string username, int accountId, bool gender)
 {
     using (var packet = new OutPacket(SendOpcodes.LoginStatus))
     {
         packet.WriteByte(0x00);
         packet.WriteInt(accountId);
         packet.WriteBool(gender);
         packet.WriteShort(0);
         packet.WriteMapleString(username);
         packet.WriteBytes(new byte[]
                           { 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0xE2, 0xED, 0xA3, 0x7A, 0xFA, 0xC9, 0x01 });
         packet.WriteInt(0);
         packet.WriteLong(0);
         packet.WriteMapleString(accountId.ToString());
         packet.WriteMapleString(username);
         packet.WriteByte(0x01);
         return(packet);
     }
 }
Beispiel #7
0
        public static void OnCheckDuplicatedID(MapleClient c, InPacket p)
        {
            string name  = p.ReadMapleString();
            bool   taken = !Database.Instance.NameAvailable(name);

            using (OutPacket packet = new OutPacket(SendOps.CheckDuplicatedIDResult))
            {
                packet.WriteMapleString(name);
                packet.WriteBool(taken);
                c.Send(packet);
            }
        }
Beispiel #8
0
 public static byte[] Handshake()
 {
     using (OutPacket p = new OutPacket())
     {
         p.WriteShort(14);
         p.WriteShort(Constants.MajorVersion);
         p.WriteMapleString(Constants.MinorVersion);
         p.WriteBytes(Constants.RIV);
         p.WriteBytes(Constants.SIV);
         p.WriteByte(Constants.Locale);
         return(p.ToArray());
     }
 }
Beispiel #9
0
        public static void HandleCharacterNameCheck(MapleClient client, InPacket iPacket)
        {
            string name     = iPacket.ReadMapleString();
            bool   unusable = (long)Database.Scalar("SELECT COUNT(*) FROM `characters` WHERE `name` = @name", new MySqlParameter("name", name)) != 0;

            using (OutPacket oPacket = new OutPacket(SendOps.CheckDuplicatedIDResult))
            {
                oPacket
                .WriteMapleString(name)
                .WriteBool(unusable);

                client.Send(oPacket);
            }
        }
Beispiel #10
0
        public void Notify(string message, NoticeType type = NoticeType.Pink)
        {
            using (OutPacket oPacket = new OutPacket(SendOps.BroadcastMsg))
            {
                oPacket.WriteByte((byte)type);

                if (type == NoticeType.Ticker)
                {
                    oPacket.WriteBool(!string.IsNullOrEmpty(message));
                }

                oPacket.WriteMapleString(message);

                this.Client.Send(oPacket);
            }
        }
Beispiel #11
0
        public static void HandleWorldList(MapleClient client, InPacket iPacket)
        {
            foreach (WorldServer world in MasterServer.Instance.Worlds)
            {
                using (OutPacket oPacket = new OutPacket(SendOps.WorldInformation))
                {
                    oPacket
                    .WriteByte(world.ID)
                    .WriteMapleString(world.Name)
                    .WriteByte()
                    .WriteMapleString(string.Empty)
                    .WriteShort(100)
                    .WriteShort(100)
                    .WriteByte()
                    .WriteByte((byte)world.Channels.Length);

                    foreach (ChannelServer channel in world.Channels)
                    {
                        oPacket
                        .WriteMapleString(string.Format("{0}-{1}", world.Name, channel.ID))
                        .WriteInt()
                        .WriteByte(1)
                        .WriteShort(channel.ID);
                    }

                    oPacket.WriteShort();

                    client.Send(oPacket);
                }
            }

            using (OutPacket oPacket = new OutPacket(SendOps.WorldInformation))
            {
                oPacket.WriteByte(byte.MaxValue);

                client.Send(oPacket);
            }
        }
Beispiel #12
0
        public static void OnCheckPassword(MapleClient c, InPacket p)
        {
            string user = p.ReadMapleString().Trim();
            string pass = p.ReadMapleString();

            //byte[] machineId = p.ReadBytes(0x10);
            //int gameRoomCode = p.ReadInt();
            //byte gameStartMode = p.ReadByte();
            //bool adminClient = p.ReadBool();

            byte loginResult = MasterServer.Instance.LoginClient(c, user, pass);

            using (OutPacket packet = new OutPacket(SendOps.CheckPasswordResult))
            {
                packet.WriteByte(loginResult);
                packet.WriteZero(5); //v11 (1) + v12 (4)

                if (loginResult == 0)
                {
                    packet.WriteInt(c.Account.AccountId);
                    packet.WriteByte();
                    packet.WriteBool(c.Account.GM);
                    packet.WriteByte(1);
                    packet.WriteMapleString(c.Account.Username);
                    packet.WriteZero(12);
                }
                else if (loginResult == 2) //TODO : Add packet for this
                {
                    c.Close();
                    return;
                }

                packet.WriteZero(24); //padding
                c.Send(packet);
            }

            if (loginResult != 0)
            {
                return;
            }

            using (OutPacket packet = new OutPacket(SendOps.CheckUserLimitResult, 3))
            {
                packet.WriteByte(4);
                c.Send(packet);
            }

            using (OutPacket packet = new OutPacket(SendOps.WorldInformation))
            {
                byte   worldId = 0;
                string name    = Constants.WorldName;

                packet.WriteByte(worldId);
                packet.WriteMapleString(name);

                packet.WriteByte((byte)MasterServer.Instance.Channels.Length);

                int id = 1;

                foreach (var ch in MasterServer.Instance.Channels)
                {
                    packet.WriteMapleString("{0}-{1}", name, id++);
                    packet.WriteInt(ch.Load);
                    packet.WriteByte(worldId);
                    packet.WriteByte((byte)(id - 1));
                    packet.WriteByte(0x00);
                }

                c.Send(packet);
            }

            using (OutPacket packet = new OutPacket(SendOps.WorldInformation, 3))
            {
                packet.WriteByte(0xff);
                c.Send(packet);
            }
        }