Пример #1
0
        public static void HandleCharacterList(MapleConnection connection, InPacket packet)
        {
            bool viewAllCharacters = packet.ReadBool();
            byte count             = packet.ReadByte();

            for (byte b = 0; b < count; b++)
            {
                Character character = new Character();

                character.Index = b;

                HelpPacket.DecodeCharacterStatistics(character, packet);
                HelpPacket.DecodeCharacterAppearance(character, packet);

                packet.ReadByte();

                if (packet.ReadBool())
                {
                    packet.ReadBytes(16); // NOTE: Ranking.
                }

                character.AvatarUrl = "http://direct.craftnet.nl/maplestory_get_rank_info.php?name=" + character.Name + "&get_character_image";

                Main.Instance.DrawCharacterTile(character);
            }

            MapleConnection.User.PicMode = (PicMode)packet.ReadByte();

            Main.Instance.SetTab(Indexer.CharacterSelect);
        }
        private void OnCharacterNameCheckResponse(InPacket inPacket)
        {
            string name  = inPacket.ReadString();
            bool   taken = inPacket.ReadBool();

            this.World.CharacterNamePool.Enqueue(name, taken);
        }
Пример #3
0
        public static void HandleSetField(MapleConnection connection, InPacket packet)
        {
            connection.Character = new Character();

            ushort loopCount = packet.ReadUShort();

            for (int i = 0; i < loopCount; i++)
            {
                packet.ReadLong();
            }

            int gameServerId = packet.ReadInt();

            packet.ReadByte();
            packet.ReadInt();
            connection.Character.PortalCount = packet.ReadByte();
            packet.ReadInt();

            bool characterData = packet.ReadBool();

            if (characterData)
            {
                HelpPacket.DecodeCharacterData(connection.Character, packet);
            }
            else
            {
            }

            Main.Instance.SetField(new Bitmap(1500, 2000));
        }
Пример #4
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                GameOpcodes uOpcode    = (GameOpcodes)iPacket.ReadShort();
                int         uSize      = iPacket.ReadInt();
                bool        isCompress = iPacket.ReadBool();
                int         cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogInfo("Pacote comprimido {0}({1})", (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("Packet {0}({1})", (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());

                switch (uOpcode)
                {
                case GameOpcodes.HEART_BIT_NOT:
                    OnHeartBeatNot();
                    break;

                case GameOpcodes.EVENT_INVITE_REQ:     //31 EVENT_FRIEND_LIST_REQ
                    MsgUser.FriendList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_ROOM_ACK:     //34 ADD_FRIEND
                    MsgUser.Add(this, iPacket);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("Pacote indefinido foi recebida. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogFatal(e);
                Close();
            }
        }
Пример #5
0
        public static void OnLISENCE_RESULT(MapleClient c, InPacket p)
        {
            var isAgree = p.ReadBool();

            if (isAgree)
            {
                c.State = LoginStateType.NotLogin;
                c.Send(LoginPacket.LicenseResult());
            }
            else
            {
                c.Close();
            }
        }
Пример #6
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                CenterOpcodes uOpcode    = (CenterOpcodes)iPacket.ReadShort();
                int           uSize      = iPacket.ReadInt();
                bool          isCompress = iPacket.ReadBool();
                int           cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogInfo("Pacote comprimido {0}({1})", (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("Packet {0}({1})", (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());

                switch (uOpcode)
                {
                case CenterOpcodes.HEART_BIT_NOT:
                    OnHeartBeatNot();
                    break;

                case CenterOpcodes.ENU_CLIENT_CONTENTS_FIRST_INIT_INFO_REQ:
                    MyLoading.NotifyContentInfo(this);
                    break;

                case CenterOpcodes.ENU_VERIFY_ACCOUNT_REQ:
                    MyUser.OnLogin(this, iPacket);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("Pacote indefinido foi recebida. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogError(e.ToString());
                Close();
            }
        }
Пример #7
0
        public override void Handle(User sender, InPacket packetReader)
        {
            if (sender.Authenticated)
            {
                if (sender.Room == null)
                {
                    sbyte direction   = (sbyte)(packetReader.ReadSbyte(0) - packetReader.ReadSbyte(2));
                    bool  waitingOnly = packetReader.ReadBool(1);

                    if (direction == -1)
                    {
                        if (sender.RoomListPage > 0)
                        {
                            sender.RoomListPage = (byte)(sender.RoomListPage - 1);
                        }
                        else
                        {
                            sender.RoomListPage = 0;
                        }
                    }
                    else if (direction == 1 && sender.RoomListPage < byte.MaxValue)
                    {
                        sender.RoomListPage += 1;
                    }

                    var result = Managers.ChannelManager.Instance.Get(sender.Channel).Rooms.Select(n => n.Value);

                    if (waitingOnly)
                    {
                        result = result.Where(n => n.State == Enums.RoomState.Waiting).OrderByDescending(n => n.ID).Take(8).OrderBy(n => n.ID);
                    }
                    else
                    {
                        result = result.Where(n => n.ID >= (uint)(8 * sender.RoomListPage) && n.ID < (uint)(8 * (sender.RoomListPage + 1))).OrderBy(n => n.ID);
                    }

                    sender.Send(new Packets.RoomList(sender.RoomListPage, new ArrayList(result.ToArray())));
                }
            }
            else
            {
                sender.Disconnect(); // Unauthorized user.
            }
        }
Пример #8
0
        public static void OnChat(MapleClient client, InPacket iPacket)
        {
            string text  = iPacket.ReadMapleString();
            bool   shout = iPacket.ReadBool(); // NOTE: Used for skill macros.

            if (text.StartsWith(Constants.CommandIndiciator.ToString()))
            {
                MasterServer.Instance.Commands.Execute(client.Character, text);
            }
            else
            {
                using (OutPacket oPacket = new OutPacket(SendOps.UserChat))
                {
                    oPacket
                    .WriteInt(client.Character.ID)
                    .WriteBool(client.Character.IsGm)
                    .WriteMapleString(text)
                    .WriteBool(shout);

                    client.Character.Map.Broadcast(oPacket);
                }
            }
        }
Пример #9
0
        public override void Handle(User sender, InPacket packetReader)
        {
            if (sender.Authenticated)
            {
                bool equipItem    = !packetReader.ReadBool();
                byte bTargetClass = packetReader.ReadByte();
                if (bTargetClass < Objects.Inventory.Equipment.MAX_CLASSES)
                {
                    Classes targetClass = (Classes)bTargetClass;
                    string  weaponCode  = packetReader.ReadString(4).ToUpper();
                    byte    targetSlot  = 0;

                    if (weaponCode.Length == 4)
                    {
                        if (targetSlot < 8)
                        {
                            if (equipItem)
                            {
                                targetSlot = packetReader.ReadByte(5);
                                if (targetSlot < Objects.Inventory.Equipment.MAX_SLOTS)
                                {
                                    if (Managers.ItemManager.Instance.Items.ContainsKey(weaponCode))
                                    {
                                        Objects.Items.ItemData item = null;
                                        if (Managers.ItemManager.Instance.Items.TryGetValue(weaponCode, out item))
                                        {
                                            if (item.IsWeapon)
                                            {
                                                Objects.Items.Weapon weapon = (Objects.Items.Weapon)item;
                                                if (weapon != null)
                                                {
                                                    if (weapon.Active && weapon.CanEquip[(byte)targetClass, targetSlot])
                                                    {
                                                        Objects.Inventory.Item equipmentItem = sender.Inventory.Get(weapon.Code);
                                                        if (equipmentItem != null && equipmentItem.Slot >= 0)
                                                        { // Does the user have the item.
                                                            Objects.Inventory.Item equipedItem = sender.Inventory.Equipment.Get(targetClass, targetSlot);
                                                            if (equipedItem == null || equipmentItem.Slot != equipedItem.Slot)
                                                            {
                                                                // string Type = getBlock(2);
                                                                if (equipmentItem.Equiped[(byte)targetClass] >= 0)
                                                                {
                                                                    sender.Inventory.Equipment.Remove(targetClass, (byte)equipmentItem.Equiped[(byte)targetClass]);
                                                                }

                                                                sender.Inventory.Equipment.Add(targetClass, targetSlot, equipmentItem);
                                                                sender.Inventory.Equipment.Build();
                                                                sender.Inventory.Equipment.BuildInternal();
                                                                sender.Send(new Packets.Equipment(targetClass, sender.Inventory.Equipment.ListsInternal[(byte)targetClass]));
                                                            }
                                                            else
                                                            {
                                                                sender.Send(new Packets.Equipment(Packets.Equipment.ErrorCode.AlreadyEquipped)); // Already equiped.
                                                            }
                                                        }
                                                        else
                                                        {
                                                            bool isFound = false; // ATTAMPT TO CHECK IF THE ITEM IS A DEFAULT ITEM.
                                                            Objects.Inventory.Item equipedItem = sender.Inventory.Equipment.Get(targetClass, targetSlot);
                                                            for (byte j = 0; j < Objects.Inventory.Inventory.DEFAULT_ITEMS.Length; j++)
                                                            {
                                                                if (weaponCode == Objects.Inventory.Inventory.DEFAULT_ITEMS[j])
                                                                {
                                                                    isFound = true;
                                                                    if (equipedItem == null || equipedItem.Slot != -1)
                                                                    {
                                                                        sender.Inventory.Equipment.Add(targetClass, targetSlot, new Objects.Inventory.Item(-1, 0, Objects.Inventory.Inventory.DEFAULT_ITEMS[j], 0));
                                                                        sender.Inventory.Equipment.Build();
                                                                        sender.Inventory.Equipment.BuildInternal();
                                                                        sender.Send(new Packets.Equipment(targetClass, sender.Inventory.Equipment.ListsInternal[(byte)targetClass]));
                                                                    }
                                                                    else
                                                                    {
                                                                        sender.Send(new Packets.Equipment(Packets.Equipment.ErrorCode.AlreadyEquipped)); // Already equiped.
                                                                    }
                                                                    break;
                                                                }
                                                            }
                                                            if (!isFound)
                                                            {
                                                                sender.Disconnect(); // potentiality scripting or packet changing.. TODO: LOG
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        sender.Disconnect(); // potentiality scripting or packet changing.. TODO: LOG
                                                    }
                                                }
                                                else
                                                {
                                                    sender.Disconnect(); // Server error?
                                                }
                                            }
                                        }
                                        else
                                        {
                                            sender.Disconnect(); // Server error?
                                        }
                                    }
                                    else
                                    {
                                        sender.Disconnect(); // potentiality scripting or packet changing.. TODO: LOG
                                    }
                                }
                                else
                                {
                                    sender.Disconnect(); // potentiality scripting or packet changing.. TODO: LOG
                                }
                            }
                            else
                            {
                                targetSlot = packetReader.ReadByte(3);
                                Objects.Inventory.Item equipedItem = sender.Inventory.Equipment.Get(targetClass, targetSlot);
                                if (equipedItem != null)
                                {
                                    sender.Inventory.Equipment.Remove(targetClass, targetSlot);
                                    sender.Inventory.Equipment.Build();
                                    sender.Send(new Packets.Equipment(targetClass, sender.Inventory.Equipment.Lists[(byte)targetClass]));
                                }
                            }
                        }
                    }
                }
                else
                {
                    sender.Disconnect();
                }
            }
        }
Пример #10
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                GameOpcodes uOpcode    = (GameOpcodes)iPacket.ReadUShort();
                int         uSize      = iPacket.ReadInt();
                bool        isCompress = iPacket.ReadBool();
                int         cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogWarning("[{0}] pacote comprimido chegada {1} ({2})", Login, (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("[{0}] de chegada de pacotes {1} ({2})", Login, (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());

                switch (uOpcode)
                {
                case GameOpcodes.EVENT_HEART_BIT_NOT:     // 0
                    OnHeartBeatNot();
                    break;

                case GameOpcodes.EVENT_CHANGE_CHARACTER_INFO_REQ:     //1618
                    InfoChars.ChangeCharInfo(this);
                    break;

                case GameOpcodes.EVENT_VERIFY_ACCOUNT_REQ:     // 2
                    MyUser.OnLogin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_CURRENT_CHARACTER_REQ:
                    MyCommon.SetCurretChar(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_FULL_SP_INFO_REQ:     // 423 0x1A7
                    MyCommon.OnGetFullSPInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_PET_COSTUM_LIST_REQ:     // 517 0x205
                    MyCommon.OnPetCostumList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_INVEN_BUFF_ITEM_LIST_REQ:     // 1226 0x04CA
                    MyCommon.OnInvenBuffItemList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DEPOT_INFO_REQ:     // 1340 0x053C
                    MyCommon.OnDepotInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAT_CLIENT_INFO:     // 226 0x00E2
                    MyCommon.OnStatClientInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_COST_RATE_FOR_GAMBLE_BUY_REQ:     // 871 0x0367
                    MyCommon.OnCostRateForGambleBuy(this);
                    break;

                case GameOpcodes.EVENT_REGISTER_NICKNAME_REQ:     // 134 0x0086
                    MyUser.OnRegisterNick(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_IDLE_STATE_REQ:     // 835 0x0343
                    MyCommon.OnSetIDLE(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAR_SELECT_JOIN_REQ:     // 1557 0x0613
                    MyUser.OnCharSelectJoin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHOICE_BOX_LIST_REQ:     // 1012 0x03F4
                    MyCommon.OnChoiceBoxList(this);
                    break;

                case GameOpcodes.EVENT_EXP_POTION_LIST_REQ:     // 1338 0x053A
                    MyCommon.OnExpPotionList(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_CATALOG_REQ:     // 1114 0x054A
                    MyCommon.OnAgitStoreCatalog(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_MATERIAL_REQ:     // 1116 0x045C
                    MyCommon.OnAgitStoreMaterial(this);
                    break;

                case GameOpcodes.EVENT_AGIT_MAP_CATALOGUE_REQ:     // 1106 0x0452
                    MyCommon.OnAgitMapCatalogue(this);
                    break;

                case GameOpcodes.EVENT_FAIRY_TREE_LV_TABLE_REQ:     // 1184 0x04A0
                    MyCommon.OnFaityTreeLvTable(this);
                    break;

                case GameOpcodes.EVENT_INVITE_DENY_NOT:     // 348 0x015C
                    InviteDeny = iPacket.ReadBool();
                    break;

                case GameOpcodes.EVENT_GET_USER_DONATION_INFO_REQ:     // 523 0x020B
                    MyCommon.OnGetUserDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_RECOMMEND_FULL_INFO_REQ:     // 567 0x0237
                    MyCommon.OnRecommentUser(this);
                    break;

                case GameOpcodes.EVENT_USER_BINGO_DATA_REQ:     // 654 0x28E
                    MyCommon.OnUserBingoData(this);
                    break;

                case GameOpcodes.EVENT_CHANNEL_LIST_REQ:     // 14 0x0E
                    MyCommon.OnChannelList(this);
                    break;

                case GameOpcodes.EVENT_DONATION_INFO_REQ:     // 525 0x020D
                    MyCommon.OnDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_ENTER_CHANNEL_REQ:     // 12 0x0C
                    MyUser.OnEnterChannel(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_CHANNEL_NOT:     // 26
                    MyUser.OnLeaveChannel(this);
                    break;

                case GameOpcodes.EVENT_CREATE_ROOM_REQ:
                    MyUser.OnCreateRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOM_INFO_REQ:
                    CurrentRoom.OnChangeRoomInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOMUSER_INFO_REQ:
                    CurrentRoom.OnChangeUserInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_ROOM_REQ:
                    CurrentRoom.OnLeaveRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_LIST_REQ:
                    CurrentChannel.OnRoomList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_JOIN_ROOM_REQ:
                    CurrentChannel.OnJoinRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_START_GAME_REQ:
                    CurrentRoom.StartGame(this, iPacket);
                    break;

                case GameOpcodes.EVENT_RELAY_LOADING_STATE:
                    CurrentRoom.OnLoadState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LOAD_COMPLETE_NOT:
                    //MyUser.LoadComplete(this, iPacket);
                    CurrentRoom.OnLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAGE_LOAD_COMPLETE_NOT:
                    //MyUser.StageLoadComplete(this, iPacket);
                    CurrentRoom.OnStageLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_MEMBER_PING_INFO_REQ:
                    CurrentRoom.OnPingInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_ROOMUSER_IDLE_STATE_REQ:
                    CurrentRoom.OnIdleInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_END_GAME_REQ:
                    CurrentRoom.OnGameEnd(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAT_REQ:
                    CurrentChannel.OnChat(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_GAME_REQ:
                    CurrentRoom.OnLeaveGame(this, iPacket);
                    break;

                case GameOpcodes.EVENT_EQUIP_ITEM_REQ:
                    MyCharacter.OnEquipItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_LOOK_EQUIP_REQ:
                    MyCharacter.OnChangeEquipInRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_PRESS_STATE_REQ:
                    CurrentRoom.OnSetPressState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SKILL_TRAINING_REQ:
                    MyCharacter.OnTrainSkill(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_SKILL_REQ:
                    MyCharacter.OnSetSkill(this, iPacket);
                    break;

                case GameOpcodes.DB_EVENT_SYSTEM_GUIDE_COMPLETE_INFO_REQ:
                    MyCommon.SendGuideCompleteInfo(this);
                    break;

                case GameOpcodes.EVENT_CASHBACK_EXTRA_RATIO_INFO_REQ:
                    MyShop.CashRatio(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_REQ:
                    MyShop.packageInfo(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_DETAIL_REQ:
                    MyShop.packageInfoDetail(this, iPacket);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("pacote indefinido foi recebido. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogFatal(e);
                Close();
            }
        }
Пример #11
0
        public override void Handle(User sender, InPacket packetReader)
        {
            if (sender.Authenticated)
            {
                if (sender.Room != null)
                {
                    sender.Disconnect();
                }

                bool isRoomValid = true;
                // READING OUT THE ROOM DATA //
                string name           = packetReader.ReadString(0);
                bool   hasPassword    = packetReader.ReadBool(1);
                string password       = packetReader.ReadString(2);
                byte   playerCount    = packetReader.ReadByte(3);
                byte   mapId          = packetReader.ReadByte(4); // Ignore this from the client, we will use it server side.
                byte   unknown1       = packetReader.ReadByte(5); // Unknown?
                byte   unknown2       = packetReader.ReadByte(6); // Unknown?
                byte   type           = 0;
                byte   levelLimit     = 0;
                bool   premiumOnly    = false;
                bool   enableVoteKick = true;

                // VALIDATE ROOM NAME //
                if (name.Length == 0 || name.Length > 25)
                { // Name Length
                    if (name.Length != 27)
                    {
                        isRoomValid = false;
                    }
                }

                // VALIDATE ROOM PASSWORD //
                if (hasPassword && (password.Length == 0 || password == "NULL"))
                { // Password Length
                    isRoomValid = false;
                }

                // VALIDATE MAXIMUM PLAYERS //
                byte highestIndex = 0;
                switch (sender.Channel)
                {
                case Enums.ChannelType.CQC:
                {
                    highestIndex = 1;
                    break;
                }

                case Enums.ChannelType.Urban_Ops:
                {
                    highestIndex = 3;
                    break;
                }

                case Enums.ChannelType.Battle_Group:
                {
                    highestIndex = 4;
                    break;
                }

                default:
                {
                    highestIndex = 1;
                    break;
                }
                }

                if (playerCount > highestIndex)
                {
                    isRoomValid = false;
                }

                // TODO: VALIDATE THE LEVEL TYPE.

                // VALIDATE PREMIUM SETTING //
                if (sender.Premium == Enums.Premium.Free2Play && premiumOnly)
                {
                    isRoomValid = false;
                }

                // TODO: VALIDATE SUPERMASTER & ENABLE VOTEKICK //

                if (isRoomValid)
                {
                    // FETCH OPEN ID //
                    Objects.Channel channel    = Managers.ChannelManager.Instance.Get(sender.Channel);
                    int             openRoomId = channel.GetOpenRoomID();

                    if (openRoomId >= 0)
                    {
                        Entities.Room room = new Entities.Room(sender, (uint)openRoomId, name, hasPassword, password, playerCount, type, levelLimit, premiumOnly, enableVoteKick);
                        if (room != null)
                        {
                            // ROOM CREATED SUCCESSFULLY //
                            Managers.ChannelManager.Instance.Get(room.Channel).Add(room);

                            sender.Send(new Packets.RoomCreation(room));

                            // SEND THE ROOM UPDATE TO THE LOBBY //
                            byte roomPage   = (byte)Math.Floor((decimal)(room.ID / 8));
                            var  targetList = Managers.ChannelManager.Instance.Get(room.Channel).Users.Select(n => n.Value).Where(n => n.RoomListPage == roomPage && n.Room == null);
                            if (targetList.Count() > 0)
                            {
                                byte[] outBuffer = new Packets.RoomUpdate(room, false).BuildEncrypted();
                                foreach (Entities.User usr in targetList)
                                {
                                    usr.Send(outBuffer);
                                }
                            }
                        }
                        else
                        {
                            channel.ForceFreeSlot(openRoomId); // Force the room slot open again.
                            sender.Send(new Packets.RoomCreation(Enums.RoomCreationErrors.GenericError));
                        }
                    }
                    else
                    {
                        sender.Send(new Packets.RoomCreation(Enums.RoomCreationErrors.MaxiumRoomsExceeded));
                    }
                }
                else
                {
                    sender.Send(new Packets.RoomCreation(Enums.RoomCreationErrors.GenericError));
                }
            }
            else
            {
                sender.Disconnect();
            }
        }
Пример #12
0
        public static void DecodeCharacterStatistics(Character character, InPacket packet)
        {
            character.ID     = packet.ReadInt();
            character.Name   = packet.ReadString(13).Replace("\0", "");
            character.Gender = packet.ReadByte();
            character.Skin   = packet.ReadByte();
            character.Face   = packet.ReadInt();
            character.Hair   = packet.ReadInt();

            for (int i = 0; i < 3; i++)
            {
                packet.ReadLong(); // Pet i's Unique ID.
            }

            character.Level        = packet.ReadByte();
            character.Job          = packet.ReadShort();
            character.Strength     = packet.ReadShort();
            character.Dexterity    = packet.ReadShort();
            character.Intelligence = packet.ReadShort();
            character.Luck         = packet.ReadShort();
            character.CurrentHP    = packet.ReadInt();
            character.MaxMP        = packet.ReadInt();
            character.CurrentMP    = packet.ReadInt();
            character.MaxMP        = packet.ReadInt();
            character.AvailableAP  = packet.ReadShort();

            bool  separated = true;
            short job       = character.Job;

            if ((job / 1000) == 1)
            {
                if ((((job % 1000) / 100) == 2) || (((job % 1000) / 100) == 4))
                {
                    separated = false;
                }
            }

            if (character.IsBeastTamer || job == 800 || ((job / 100) == 9) || (((job / 1000) == 2) && (((job % 1000) / 100)) == 1))
            {
                separated = false;
            }

            if (separated)
            {
                byte count = packet.ReadByte();

                for (byte b = 0; b < count; b++)
                {
                    byte advancement = packet.ReadByte();
                    int  value       = packet.ReadInt();

                    character.AvailableSP[advancement] = value;
                }
            }
            else
            {
                character.AvailableSP[0] = packet.ReadShort();
            }

            character.Experience         = packet.ReadLong();
            character.Fame               = packet.ReadInt();
            character.WeaponPoints       = packet.ReadInt(); // Zero Weapon Points
            character.GachaponExperience = packet.ReadInt();
            character.FieldID            = packet.ReadInt();
            character.SpawnPoint         = packet.ReadByte();
            packet.ReadInt();
            packet.ReadShort();

            if (character.IsDemonSlayer || character.IsDemonAvenger || character.IsXenon || character.IsBeastTamer)
            {
                character.FaceMarking = packet.ReadInt();
            }

            packet.ReadByte(); // Fatigue
            packet.ReadInt();  // Current Date

            for (int i = 0; i < 6; i++)
            {
                packet.ReadInt(); // Traits (Total)
            }

            packet.ReadBytes(21);
            character.BattleExperience = packet.ReadInt();
            character.BattleRank       = packet.ReadByte();
            character.BattlePoints     = packet.ReadInt();
            packet.ReadByte();
            packet.ReadByte();
            packet.ReadInt();

            // Part Time Job
            {
                packet.ReadByte();
                packet.ReadReversedLong();
                packet.ReadInt();
                packet.ReadBool();
            }

            // Character Cards
            {
                for (int i = 0; i < 9; i++)
                {
                    packet.ReadInt();
                    packet.ReadByte();
                    packet.ReadInt();
                }
            }

            packet.ReadLong();
        }
Пример #13
0
        public static void DecodeCharacterAppearance(Character character, InPacket packet)
        {
            character.Gender = packet.ReadByte();
            character.Skin   = packet.ReadByte();
            character.Face   = packet.ReadInt();
            character.Job    = (short)packet.ReadInt();
            packet.ReadBool(); // NOTE: In earlier versions, hair used to be an equip slot.
            character.Hair = packet.ReadInt();

            // Shown Layer
            {
                byte slot = packet.ReadByte();

                while (slot != byte.MaxValue)
                {
                    packet.ReadInt(); // Item Maple ID
                    slot = packet.ReadByte();
                }
            }

            // Hidden Layer
            {
                byte slot = packet.ReadByte();

                while (slot != byte.MaxValue)
                {
                    packet.ReadInt(); // Item Maple ID
                    slot = packet.ReadByte();
                }
            }

            // Totem Layer
            {
                byte slot = packet.ReadByte();

                while (slot != byte.MaxValue)
                {
                    packet.ReadInt(); // Item Maple ID
                    slot = packet.ReadByte();
                }
            }

            packet.ReadInt();     // Cash Weapon Maple ID
            packet.ReadInt();     // Weapon Maple ID
            packet.ReadInt();     // Shield Maple ID
            packet.ReadBool();    // Mercedes Ears
            packet.ReadBytes(12); // Pets' Maple IDs

            if (character.IsDemonSlayer || character.IsDemonAvenger || character.IsXenon || character.IsBeastTamer)
            {
                character.FaceMarking = packet.ReadInt();
            }
            else if (character.IsZero)
            {
                packet.ReadBool();
            }

            if (character.IsBeastTamer)
            {
                if (packet.ReadBool())
                {
                    packet.ReadInt(); // Tale Effect
                }

                if (packet.ReadBool())
                {
                    packet.ReadInt(); // Ears Effect
                }
            }
        }
Пример #14
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                CenterOpcodes uOpcode    = (CenterOpcodes)iPacket.ReadShort();
                int           uSize      = iPacket.ReadInt();
                bool          isCompress = iPacket.ReadBool();
                int           cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogWarning("Recebido Pacote Compress  {0}({1})", (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("Pacote Recebido {0}({1})", (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex(uOpcode + ": ", iPacket.ToArray());

                switch (uOpcode)
                {
                case CenterOpcodes.HEART_BIT_NOT:
                    OnHeartBeatNot();
                    break;

                case CenterOpcodes.ENU_CLIENT_CONTENTS_FIRST_INIT_INFO_REQ:
                    MyLoading.NotifyContentInfo(this, iPacket);
                    break;

                case CenterOpcodes.ENU_SHAFILENAME_LIST_REQ:
                    MyLoading.NotifySHAFile(this, iPacket);
                    break;

                case CenterOpcodes.ENU_VERIFY_ACCOUNT_REQ:
                    MyUser.OnLogin(this, iPacket);
                    break;

                case CenterOpcodes.ENU_CLIENT_PING_CONFIG_REQ:
                    OnClientPingConfig();
                    break;

                case CenterOpcodes.ENU_GUIDE_BOOK_LIST_REQ:
                    MyUser.OnGuideBookList(this);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("Pacote Desconhecido Recebido. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogError(e.ToString());
                Close();
            }
        }
Пример #15
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                GameOpcodes uOpcode    = (GameOpcodes)iPacket.ReadUShort();
                int         uSize      = iPacket.ReadInt();
                bool        isCompress = iPacket.ReadBool();
                int         cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogWarning("[{0}] Pacote comprimido {1}({2})", Login, (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("[{0}] Packet {1}({2})", Login, (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex("Pacote: ", iPacket.ToArray());

                switch (uOpcode)
                {
                case GameOpcodes.HEART_BIT_NOT:     // 0
                    OnHeartBeatNot();
                    break;

                case GameOpcodes.EVENT_VERIFY_ACCOUNT_REQ:     // 2
                    MyUser.OnLogin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_FULL_SP_INFO_REQ:     // 423 0x1A7
                    MyCommon.OnGetFullSPInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_PET_COSTUM_LIST_REQ:     // 517 0x205
                    MyCommon.OnPetCostumList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_INVEN_BUFF_ITEM_LIST_REQ:     // 1226 0x04CA
                    MyCommon.OnInvenBuffItemList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DEPOT_INFO_REQ:     // 1340 0x053C
                    MyCommon.OnDepotInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAT_CLIENT_INFO:     // 226 0x00E2
                    MyCommon.OnStatClientInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_COST_RATE_FOR_GAMBLE_BUY_REQ:     // 871 0x0367
                    MyCommon.OnCostRateForGambleBuy(this);
                    break;

                case GameOpcodes.EVENT_ENTER_AGIT_REQ:    //AGITT
                    MyAgit.EnterAgit(this);
                    break;

                case GameOpcodes.EVENT_AGIT_LOADING_COMPLETE_REQ:    //AGITT
                    MyAgit.AgitLoadComplete(this);
                    break;

                case GameOpcodes.EVENT_REGISTER_NICKNAME_REQ:     // 134 0x0086
                    MyUser.OnRegisterNick(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_IDLE_STATE_REQ:     // 835 0x0343
                    MyCommon.OnSetIDLE(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAR_SELECT_JOIN_REQ:     // 1555 0x0613
                    MyUser.OnCharSelectJoin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHOICE_BOX_LIST_REQ:     // 1012 0x03F4
                    MyCommon.OnChoiceBoxList(this);
                    break;

                case GameOpcodes.EVENT_EXP_POTION_LIST_REQ:     // 1338 0x053A
                    MyCommon.OnExpPotionList(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_CATALOG_REQ:     // 1114 0x054A
                    MyCommon.OnAgitStoreCatalog(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_MATERIAL_REQ:     // 1116 0x045C
                    MyCommon.OnAgitStoreMaterial(this);
                    break;

                case GameOpcodes.EVENT_AGIT_MAP_CATALOGUE_REQ:     // 1106 0x0452
                    MyCommon.OnAgitMapCatalogue(this);
                    break;

                case GameOpcodes.EVENT_FAIRY_TREE_LV_TABLE_REQ:     // 1184 0x04A0
                    MyCommon.OnFaityTreeLvTable(this);
                    break;

                case GameOpcodes.EVENT_INVITE_DENY_NOT:     // 348 0x015C
                    InviteDeny = iPacket.ReadBool();
                    break;

                case GameOpcodes.EVENT_GET_USER_DONATION_INFO_REQ:     // 523 0x020B
                    MyCommon.OnGetUserDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_RECOMMEND_FULL_INFO_REQ:     // 567 0x0237
                    MyCommon.OnRecommentUser(this);
                    break;

                case GameOpcodes.EVENT_USER_BINGO_DATA_REQ:     // 654 0x28E
                    MyCommon.OnUserBingoData(this);
                    break;

                case GameOpcodes.EVENT_CHANNEL_LIST_REQ:     // 14 0x0E
                    MyCommon.OnChannelList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DONATION_INFO_REQ:     // 525 0x020D
                    MyCommon.OnDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_ENTER_CHANNEL_REQ:     // 12 0x0C
                    MyUser.OnEnterChannel(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_CHANNEL_NOT:     // 26
                    MyUser.OnLeaveChannel(this);
                    break;

                case GameOpcodes.EVENT_CREATE_ROOM_REQ:     // 24 방 만들기
                    MyUser.OnCreateRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOM_INFO_REQ:     // 28 0x1C 방의 게임모드 정보 바뀜
                    CurrentRoom.OnChangeRoomInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOMUSER_INFO_REQ:     // 40 0x28 방의 유저 정보 바뀜
                    CurrentRoom.OnChangeUserInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_ROOM_REQ:     // 33 0x21 방에서 나가기 요청
                    CurrentRoom.OnLeaveRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_LIST_REQ:     // 16 0x10 방 목록 요청
                    CurrentChannel.OnRoomList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_JOIN_ROOM_REQ:     // 20 방 입장 요청
                    CurrentChannel.OnJoinRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_START_GAME_REQ:     // 36 게임 시작 요청
                    CurrentRoom.OnGameStart(this, iPacket);
                    break;

                case GameOpcodes.EVENT_RELAY_LOADING_STATE:     // 842 게임로딩중 로딩진행도
                    CurrentRoom.OnLoadState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LOAD_COMPLETE_NOT:     // 39 로딩 끝났다는거 전송 (게임으로 들여보내짐)
                    CurrentRoom.OnLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAGE_LOAD_COMPLETE_NOT:     // 927 스테이지 로딩이 끝났다
                    CurrentRoom.OnStageLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_MEMBER_PING_INFO_REQ:     // 837 게임 멤버 핑 정보 요청 (게임시작 할때 쓰나봄)
                    CurrentRoom.OnPingInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_ROOMUSER_IDLE_STATE_REQ:     // 833 자리비움 상태 요청
                    CurrentRoom.OnIdleInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_END_GAME_REQ:     // 게임 종료
                    CurrentRoom.OnGameEnd(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAT_REQ:     // 6 채팅!
                    CurrentChannel.OnChat(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_GAME_REQ:     // 44 게임중 나가기
                    CurrentRoom.OnLeaveGame(this, iPacket);
                    break;

                case GameOpcodes.EVENT_EQUIP_ITEM_REQ:     // 62 장비 변경 요청
                    MyCharacter.OnEquipItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_LOOK_EQUIP_REQ:     // 860 방에서 장비변경 요청 (이게 선처리 된 후 EVENT_EQUIP_ITEM_REQ)
                    MyCharacter.OnChangeEquipInRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_PRESS_STATE_REQ:     // 방에서 다른 용무중
                    CurrentRoom.OnSetPressState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SKILL_TRAINING_REQ:     // 스킬 배우기
                    MyCharacter.OnTrainSkill(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_SKILL_REQ:     // 스킬 장착 요청
                    MyCharacter.OnSetSkill(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SERVER_LIST_REQ:
                    MyUser.SendServerList(this);
                    break;

                case GameOpcodes.EVENT_SQUARE_LIST_REQ:
                    square.SquareList(this);
                    break;

                case GameOpcodes.EVENT_ENTER_SQUARE_REQ:
                    square.enterSquare(this);
                    break;

                case GameOpcodes.EVENT_LEAVE_SQUARE_REQ:
                    square.LeaveSquare(this);
                    break;

                case GameOpcodes.EVENT_CASHBACK_EXTRA_RATIO_INFO_REQ:
                    MyShop.CashRatio(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_REQ:
                    MyShop.packageInfo(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_DETAIL_REQ:
                    MyShop.packageInfoDetail(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ITEM_BUY_CHECK_REQ:
                    MyShop.CheckItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_BUY_VIRTUAL_CASH_REQ:
                    MyShop.BuyVP(this, iPacket);
                    break;

                case GameOpcodes.EVENT_BUY_FOR_GP_REQ:
                    MyShop.BuyGP(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHARISMAS_EVENT_INFO_REQ:
                    MyCommon.Event_Gifts(this);
                    break;

                case GameOpcodes.EVENT_CHECK_ROOM_USERLIST_NOT:
                    CurrentRoom.checkRoomUser(this);
                    break;

                case GameOpcodes.EVENT_STAT_LOADING_TIME_NOT:
                    CurrentRoom.statLoadingTime(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SPECIAL_REWARD_REQ:
                    CurrentRoom.RewardItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DEPOT_CHAR_TAB_INFO_REQ:
                    GachaList.Depot_Char_tab(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GACHA_REWARD_LIST_REQ:
                    GachaList.Gacha_Reward_List(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GACHA_SET_REWARD_LIST_REQ:
                    GachaList.Gacha_SET_Reward_List(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GACHA_LEVEL_ACTION_REQ:
                    GachaList.Gacha_Action(this, iPacket);
                    break;

                case GameOpcodes.EVENT_REMOVE_MISSION_REQ:
                    MyQuests.RemoveMission(this, iPacket);
                    break;

                case GameOpcodes.EVENT_REGIST_MISSION_REQ:
                    MyQuests.RegisterMission(this, iPacket);
                    break;

                case GameOpcodes.EVENT_COMPLETE_MISSION_REQ:
                    MyQuests.CompleteMission(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CREATE_PET_REQ:
                    MyPet.create_pet(this, iPacket);
                    break;

                case GameOpcodes.EVENT_HERO_ITEM_CATALOG_REQ:
                    heroico.Hero_Item_Catalog(this);
                    break;

                case GameOpcodes.EVENT_HERO_ITEM_MATERIAL_REQ:
                    heroico.Hero_Item_Material(this);
                    break;

                case GameOpcodes.EVENT_MANUFACTURES3_CATALOG_REQ:
                    manufacture.Manufacture_Catalog(this);
                    break;

                case GameOpcodes.EVENT_SPECIFIC_ITEM_BREAKUP_INFO_REQ:
                    manufacture.SpecificItemBreakup(this);
                    break;

                case GameOpcodes.EVENT_MANUFACTURES3_MATERIAL_REQ:
                    manufacture.ManuFactureMaterial(this);
                    break;

                case GameOpcodes.EVENT_DUNGEON_REWARD_EXP_REQ:
                    CurrentRoom.RewardEXP(this, iPacket);
                    break;

                case GameOpcodes.EVENT_USER_LIST_REQ:
                    MyUser.ListUsers(this);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("pacote indefinido foi recebida. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote: ", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogError(e.ToString());
                Close();
            }
        }