Example #1
0
        private void ProcessCharacterListQueryPacket(SubPacket receivedPacket)
        {
            Database             db = new Database();
            CharacterQueryPacket cq = new CharacterQueryPacket();
            string accountName      = cq.ReadAccountName(receivedPacket);

            Console.WriteLine("account name for CL: " + accountName);
            var accountId = db.GetAccountIdFromAccountName(accountName);

            Console.WriteLine("ID for CL: " + accountId);
            var characterList = db.GetListOfCharacters(accountId);
            var packets       = cq.BuildResponsePacket(characterList);

            Console.WriteLine("Character packeted authenticated = " + client.authenticated);
            BasePacket packetsToSend = BasePacket.CreatePacket(packets, client.authenticated, false);

            Console.WriteLine("---Character Query Packet---");
            for (var i = 0; i < characterList.Count; i++)
            {
                int characterId = int.Parse(characterList[i][0]);
                client.CharacterIds[i] = characterId;
            }
            packetsToSend.debugPrintPacket();
            client.QueuePacket(packetsToSend);
        }
Example #2
0
        public void ProcessPacket(ClientConnection client, BasePacket packet)
        {
            this.client = client;

            //        BasePacket.DecryptPacket(client.blowfish, ref packet);

            //else
            packet.debugPrintPacket();
            List <SubPacket> subPackets = packet.GetSubpackets();

            foreach (SubPacket subPacket in subPackets)
            {
                subPacket.debugPrintSubPacket();

                if (subPacket.header.type == (ushort)SubPacketTypes.Account)
                {
                    ProcessAccountPacket(client, subPacket);
                }

                if (subPacket.header.type == (ushort)SubPacketTypes.GamePacket)
                {
                    switch (subPacket.gameMessage.opcode)
                    {
                    case (ushort)GamePacketOpCode.CreateCharacter:
                        if (CheckCharacterCreatePacket(subPacket))
                        {
                            PerformCharacterCreate(subPacket);
                        }
                        break;

                    case (ushort)GamePacketOpCode.CharacterListQuery:
                        ProcessCharacterListQueryPacket(subPacket);
                        break;

                    case (ushort)GamePacketOpCode.CharacterDeleteQuery:
                        ProcessCharacterDeleteRequest(subPacket);
                        break;

                    case (ushort)GamePacketOpCode.Handshake:
                        ProcessHandshake(subPacket);
                        break;
                    }
                }
            }
        }