Esempio n. 1
0
        public ClientSession(Socket pSocket) : base(pSocket)
        {
            IP = BitConverter.ToUInt32(IPAddress.Parse(GetIP()).GetAddressBytes(), 0);

            InitiateReceive(2, true);
            CRYPT_KEY  = CryptoGenerators.GenerateKey();
            CRYPT_HMAC = CryptoGenerators.GenerateKey();
            byte[] TEMP_PREFIX = CryptoGenerators.GeneratePrefix();

            using (OutPacket oPacket = new OutPacket(CenterOpcodes.SET_SECURITY_KEY_NOT))
            {
                oPacket.WriteBytes(TEMP_PREFIX);
                oPacket.WriteInt((int)8);
                oPacket.WriteBytes(CRYPT_HMAC);
                oPacket.WriteInt((int)8);
                oPacket.WriteBytes(CRYPT_KEY);
                oPacket.WriteHexString("00 00 00 01 00 00 00 00 00 00 00 00");

                oPacket.Assemble(CryptoConstants.GC_DES_KEY, CryptoConstants.GC_HMAC_KEY, CRYPT_PREFIX, ++CRYPT_COUNT);
                Send(oPacket);
            }
            CRYPT_PREFIX = TEMP_PREFIX;

            using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_WAIT_TIME_NOT))
            {
                oPacket.WriteHexString("00 00 27 10");

                oPacket.Assemble(CRYPT_KEY, CRYPT_HMAC, CRYPT_PREFIX, ++CRYPT_COUNT);
                Send(oPacket);
            }
        }
Esempio n. 2
0
        public ClientSession(Socket pSocket) : base(pSocket)
        {
            IP = BitConverter.ToUInt32(IPAddress.Parse(GetIP()).GetAddressBytes(), 0);

            InitiateReceive(2, true);

            CurrentChannel = null;
            CurrentRoom    = null;

            CRYPT_KEY  = CryptoGenerators.GenerateKey();
            CRYPT_HMAC = CryptoGenerators.GenerateKey();
            byte[] TEMP_PREFIX = CryptoGenerators.GeneratePrefix(); // Prefix

            LogFactory.GetLog("Main").LogHex("IV: ", CRYPT_KEY);
            LogFactory.GetLog("Main").LogHex("HMAC: ", CRYPT_HMAC);

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ACCEPT_CONNECTION_NOT))
            {
                oPacket.WriteBytes(TEMP_PREFIX);
                oPacket.WriteInt((int)8);
                oPacket.WriteBytes(CRYPT_HMAC);
                oPacket.WriteInt((int)8);
                oPacket.WriteBytes(CRYPT_KEY);
                oPacket.WriteHexString("00 00 00 01 00 00 00 00 00 00 00 00");

                oPacket.Assemble(CryptoConstants.GC_DES_KEY, CryptoConstants.GC_HMAC_KEY, CRYPT_PREFIX, ++CRYPT_COUNT);
                Send(oPacket);
            }

            // Prefix
            CRYPT_PREFIX = TEMP_PREFIX;
        }
Esempio n. 3
0
        public void SendInventory(ClientSession cs)
        {
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_VERIFY_INVENTORY_NOT))
            {
                oPacket.WriteHexString("00 00 00 01 00 00 00 01");

                oPacket.WriteInt(inventory.Length);
                for (int i = 0; i < inventory.Length; i++)
                {
                    oPacket.WriteInt(inventory[i].ItemID);  // ItemID
                    oPacket.WriteHexString("00 00 00 01");
                    oPacket.WriteInt(inventory[i].ItemUID); // ItemUID
                    oPacket.WriteInt(inventory[i].Quantity);
                    oPacket.WriteHexString("FF FF FF FF");

                    /*oPacket.WriteInt(inventory[i].Quantity); // Quantity
                    *  oPacket.WriteInt(inventory[i].Quantity); // Quantity*/
                    oPacket.WriteHexString("00 00 00 00 00 00 FF FF FF FF 00 00 00 00 56 76 0D AA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                    //oPacket.WriteHexString("00 00 00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                }

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 4
0
 public void CurrentVirtualCash(ClientSession cs)
 {
     using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_CURRENT_VIRTUAL_CASH_NOT))
     {
         oPacket.WriteInt(virtualCash);
         oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
         cs.Send(oPacket);
     }
 }
Esempio n. 5
0
        public void OnChat(ClientSession cs, InPacket ip)
        {
            ip.ReadByte(); // 01
            ip.ReadInt();  // 00 00 00 00
            int    WhereLen = ip.ReadInt();
            string Where    = ip.ReadUnicodeString(WhereLen);

            ip.ReadInt(); // 00 00 00 00
            ip.ReadInt(); // 00 00 00 00
            ip.ReadInt(); // FF FF FF FF
            int    ChatLen = ip.ReadInt();
            string Chat    = ip.ReadUnicodeString(ChatLen);

            if (Where == "Server")
            {
                if (cs.AuthLevel == 1)
                {
                    if (Chat.Substring(0, 1) == "!")
                    {
                        cmd.GMCommands(cs, Chat, ip);
                    }
                    else
                    {
                    }
                    if (Chat.Substring(0, 1) == "/")
                    {
                        cmd.GMCommands(cs, Chat, ip);
                    }
                }
                using (OutPacket op = new OutPacket(GameOpcodes.EVENT_CHAT_NOT))
                {
                    op.WriteByte(1);
                    op.WriteInt(cs.LoginUID);
                    op.WriteInt(cs.Nick.Length * 2);
                    op.WriteUnicodeString(cs.Nick);
                    op.WriteInt(0);
                    op.WriteInt(0);
                    op.WriteInt(-1);
                    op.WriteInt(ChatLen);
                    op.WriteUnicodeString(Chat);
                    op.WriteInt(0);
                    op.WriteInt(0);



                    foreach (ClientSession u in UsersList)
                    {
                        if (u.CurrentRoom == cs.CurrentRoom)
                        {
                            op.Assemble(u.CRYPT_KEY, u.CRYPT_HMAC, u.CRYPT_PREFIX, u.CRYPT_COUNT);
                            u.Send(op);
                            op.CancelAssemble();
                        }
                    }
                }
            }
        }
Esempio n. 6
0
 public void OnClientPingConfig()
 {
     using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_CLIENT_PING_CONFIG_ACK))
     {
         oPacket.WriteHexString("00 00 0F A0 00 00 0F A0 00 00 0F A0 00 00 00 01 00 FF FF FF FF 00 00 00 00");
         oPacket.Assemble(CRYPT_KEY, CRYPT_HMAC, CRYPT_PREFIX, ++CRYPT_COUNT);
         Send(oPacket);
     }
 }
Esempio n. 7
0
        public void SendChannelNews(ClientSession cs)
        {
            using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_CHANNEL_NEWS_NOT))
            {
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 01");

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 8
0
 public void LeaveSquare(ClientSession cs)
 {
     using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_LEAVE_SQUARE_ACK))
     {
         PlayersList.Remove(cs);
         oPacket.WriteInt(0);
         oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
         cs.Send(oPacket);
     }
 }
Esempio n. 9
0
 public void ChangeCharInfo(ClientSession cs)
 {
     using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_CHANGE_CHARACTER_INFO_ACK))
     {
         oPacket.WriteHexString("00 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 85 00 00 78 6E 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 78 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 82 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 8C 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 96 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 A0 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 AA 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 B4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 BE 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 C8 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 D2 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 DC 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 E6 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 F0 00 00 00 01 00 00 00 00 00 00 00 00 00 00 78 FA 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 04 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 18 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 22 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 2C 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 36 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 40 00 00 00 01 00 00 00 00 00 00 00 00 00 00 79 4A 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 C0 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 CA 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 D4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 DE 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 E8 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 F2 00 00 00 01 00 00 00 00 00 00 00 00 00 00 85 FC 00 00 00 01 00 00 00 00 00 00 00 00 00 00 86 06 00 00 00 01 00 00 00 00 00 00 00 00 00 00 86 10 00 00 00 01 00 00 00 00 00 00 00 00 00 00 86 1A 00 00 00 01 00 00 00 00 00 00 00 00 00 00 86 24 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 8C 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 96 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 A0 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 AA 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 B4 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 BE 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 C8 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 D2 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 DC 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 E6 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 F0 00 00 00 01 00 00 00 00 00 00 00 00 00 01 45 FA 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 04 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 18 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 22 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 2C 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 36 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 40 00 00 00 01 00 00 00 00 00 00 00 00 00 01 46 4A 00 00 00 01 00 00 00 00 00 00 00 00 00 01 9B 18 00 00 00 01 00 00 00 00 00 00 00 00 00 01 FF 40 00 00 00 01 00 00 00 00 00 00 00 00 00 01 FF 4A 00 00 00 01 00 00 00 00 00 00 00 00 00 02 1E 9E 00 00 00 01 00 00 00 00 00 00 00 00 00 02 29 A2 00 00 00 01 00 00 00 00 00 00 00 00 00 02 41 08 00 00 00 01 00 00 00 00 00 00 00 00 00 02 CA 56 00 00 00 01 00 00 00 00 00 00 00 00 00 02 CA 60 00 00 00 01 00 00 00 00 00 00 00 00 00 02 CA 6A 00 00 00 01 00 00 00 00 00 00 00 00 00 02 CA 74 00 00 00 01 00 00 00 00 00 00 00 00 00 02 D1 2C 00 00 00 01 00 00 00 00 00 00 00 00 00 02 D1 36 00 00 00 01 00 00 00 00 00 00 00 00 00 02 D1 40 00 00 00 01 00 00 00 00 00 00 00 00 00 02 D1 4A 00 00 00 01 00 00 00 00 00 00 00 00 00 02 E0 54 00 00 00 01 00 00 00 00 00 00 00 00 00 02 E0 5E 00 00 00 01 00 00 00 00 00 00 00 00 00 02 E0 68 00 00 00 01 00 00 00 00 00 00 00 00 00 02 E0 72 00 00 00 01 00 00 00 00 00 00 00 00 00 02 E0 7C 00 00 00 01 00 00 00 00 00 00 00 00 00 02 E0 86 00 00 00 01 00 00 00 00 00 00 00 00 00 03 4A 76 00 00 00 01 00 00 00 00 00 00 00 00 00 03 4A 80 00 00 00 01 00 00 00 00 00 00 00 00 00 03 4A 8A 00 00 00 01 00 00 00 00 00 00 00 00 00 03 4A 94 00 00 00 01 00 00 00 00 00 00 00 00 00 04 89 86 00 00 00 01 00 00 00 00 00 00 00 00 00 04 89 90 00 00 00 01 00 00 00 00 00 00 00 00 00 05 0F 6E 00 00 00 01 00 00 00 00 00 00 00 00 00 05 0F 78 00 00 00 01 00 00 00 00 00 00 00 00 00 05 9A 42 00 00 00 01 00 00 00 00 00 00 00 00 00 06 E2 3A 00 00 00 01 00 00 00 00 00 00 00 00 00 09 33 1A 00 00 00 01 00 00 00 00 00 00 00 00 00 09 33 24 00 00 00 01 00 00 00 00 00 00 00 00 00 09 54 66 00 00 00 01 00 00 00 00 00 00 00 00 00 0A 1E 28 00 00 00 01 00 00 00 00 00 00 00 00 00 0A 1E 32 00 00 00 01 00 00 00 00 00 00 00 00 00 0C 55 08 00 00 00 01 00 00 00 00 00 00 00 00 00 0C 55 12 00 00 00 01 00 00 00 00 00 00 00 00 00 0D 72 94 00 00 00 01 00 00 00 00 00 00 00 00 00 0D 72 9E 00 00 00 01 00 00 00 00 00 00 00 00 00 0E E9 E4 00 00 00 01 00 00 00 00 00 00 00 00 00 0E E9 EE 00 00 00 01 00 00 00 00 00 00 00 00 00 0E E9 F8 00 00 00 01 00 00 00 00 00 00 00 00 00 0E EA 02 00 00 00 01 00 00 00 00 00 00 00 00 00 0E EA 0C 00 00 00 01 00 00 00 00 00 00 00 00 00 0E EA 16 00 00 00 01 00 00 00 00 00 00 00 00 00 0F 85 98 00 00 00 01 00 00 00 00 00 00 00 00 00 0F 85 A2 00 00 00 01 00 00 00 00 00 00 00 00 00 10 49 60 00 00 00 01 00 00 00 00 00 00 00 00 00 10 49 6A 00 00 00 01 00 00 00 00 00 00 00 00 00 10 6A 3A 00 00 00 01 00 00 00 00 00 00 00 00 00 10 6A 44 00 00 00 01 00 00 00 00 00 00 00 00 00 10 A5 18 00 00 00 01 00 00 00 00 00 00 00 00 00 10 A5 22 00 00 00 01 00 00 00 00 00 00 00 00 00 10 E6 E0 00 00 00 01 00 00 00 00 00 00 00 00 00 10 E6 EA 00 00 00 01 00 00 00 00 00 00 00 00 00 12 6A A6 00 00 00 01 00 00 00 00 00 00 00 00 00 12 6A B0 00 00 00 01 00 00 00 00 00 00 00 00 00 12 6A BA 00 00 00 01 00 00 00 00 00 00 00 00 00 12 6A C4 00 00 00 01 00 00 00 00 00 00 00 00 00 12 6A CE 00 00 00 01 00 00 00 00 00 00 00 00 00 12 6A D8 00 00 00 01 00 00 00 00 00 00 00 00 00 12 9F 26 00 00 00 01 00 00 00 00 00 00 00 00 00 12 9F 30 00 00 00 01 00 00 00 00 00 00 00 00 00 12 9F 3A 00 00 00 01 00 00 00 00 00 00 00 00 00 12 9F 44 00 00 00 01 00 00 00 00 00 00 00 00 00 12 9F 4E 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 24 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 38 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 42 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 4C 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 56 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 60 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 6A 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 74 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 7E 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 88 00 00 00 01 00 00 00 00 00 00 00 00 00 13 8C 92 00 00 00 01 00 00 00 00 00 00 00 00 00 18 E5 FC 00 00 00 01 00 00 00 00 00 00 00 00 00 18 E6 06 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 02 00 14 DC DC 00 00 00 01 3B 9C 50 A1 00 00 00 00 58 ED B0 93 58 EC 5F 13 00 00 00 00 00 14 DC E6 00 00 00 01 3B 9C 50 A2 00 00 00 00 58 ED B0 93 58 EC 5F 13 00 00 00 00 00 00 00 53 00 00 00 07 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 00 0A 89 62 00 00 00 00 1C 46 C6 EB 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 02 00 00 00 02 00 02 01 41 00 00 00 01 00 01 40 A0 00 00 00 0A 89 6C 00 00 00 00 1C 46 C6 EC 00 02 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 02 00 00 00 00 01 02 00 00 00 03 00 0C 01 3D 23 6E 2F 01 09 01 00 00 00 00 02 04 01 41 D8 00 00 00 0A 89 76 00 00 00 00 1C 46 C6 ED 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 02 00 00 00 02 00 03 01 41 10 00 00 01 09 01 00 00 00 00 00 0A 89 80 00 00 00 00 1C 46 C6 EE 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 02 00 00 00 02 00 0A 01 3E 0F 5C 29 01 1C 01 3E 9E B8 52 00 0A 89 8A 00 00 00 00 1C 46 C6 F0 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 02 00 00 00 02 00 1C 01 3E 9E B8 52 01 08 01 3D A3 A2 9C 00 0A A0 BE 00 00 00 00 1C 46 C6 F1 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 02 00 00 00 02 00 07 01 3F 00 00 00 01 0C 01 3D 23 6E 2F 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 01 68 00 00 01 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF");
         //oPacket.WriteHexString("FF 09");
         oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
         cs.Send(oPacket);
     }
 }
Esempio n. 10
0
        public void OnTrainSkill(ClientSession cs, InPacket ip)
        {
            int SkillID = ip.ReadInt();


            for (int i = 0; i < MyChar.Length; i++)
            {
                Array.Resize(ref MyChar[i].MySkill, MyChar[i].MySkill.Length + 1);
                MyChar[i].MySkill[MyChar[i].MySkill.Length - 1].SkillID = SkillID;
            }

            int MyCharPos = -1;

            for (int t = 0; t < cs.MyCharacter.MyChar.Length; t++)
            {
                if (cs.MyCharacter.MyChar[t].CharType == cs.CurrentChar)
                {
                    MyCharPos = t;
                }
            }

            DataSet ds2 = new DataSet();

            Database.Query(ref ds2, "SELECT   `CharID` FROM  `skilltreeid` WHERE `SkillID` = '{0}'", SkillID);
            if (ds2.Tables[0].Rows.Count == 0)
            {
                LogFactory.GetLog("ADD SKILL").LogWarning("ESSA SKILL NAO ESTA NA DB: " + SkillID);
            }
            else
            {
                MyCharPos      = Convert.ToInt32(ds2.Tables[0].Rows[0]["CharID"].ToString());
                cs.CurrentChar = MyCharPos;
            }

            LogFactory.GetLog("ADD SKILL").LogSuccess("SKILLID: " + SkillID + " CHARID: " + MyCharPos);

            /*DataSet ds = new DataSet();
             * Database.Query(ref ds, "INSERT INTO `skilltreeid` (`SkillID`, `CharID`) VALUES  ('{0}', '{1}')",SkillID,cs.CurrentChar);*/
            DataSet ds = new DataSet();

            Database.Query(ref ds, "INSERT INTO `gc`.`skilltree` (  `loginui`,  `charindex`,  `SkillGroup`,  `SkillID`) VALUES  (    '{0}',    '{1}',    '0',    '{2}'  )", cs.LoginUID, MyCharPos, SkillID);

            /*DataSet ds = new DataSet();
             * Database.Query(ref ds, "INSERT INTO `gc`.`skilltree` (  `loginui`,  `charindex`,  `SkillGroup`,  `SkillID`) VALUES  (    '{0}',    '{1}',    '0',    '{2}'  )", cs.LoginUID,MyCharPos,SkillID);*/
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_SKILL_TRAINING_ACK))
            {
                oPacket.WriteInt(0); // 성공 여부인가봄
                oPacket.WriteInt(SkillID);

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 11
0
        public void Gacha_Action(ClientSession cs, InPacket ip)
        {
            int CharID = ip.ReadInt();
            int Set    = ip.ReadInt();
            int Level  = ip.ReadInt();
            int Gema   = ip.ReadInt();

            int rndItems = RandomItems.Next(30);
            int rndUID   = RandomItems.Next(873604976);

            if (Level == 30)
            {
                percent30(rndItems, Set);
            }
            if (Level == 40)
            {
                percent30(rndItems, Set);
            }
            if (Level == 50)
            {
                percent30(rndItems, Set);
            }
            if (Level == 60)
            {
                percent30(rndItems, Set);
            }
            if (Level == 70)
            {
                percent50(rndItems, Set);
            }
            if (Level == 80)
            {
                percent50(rndItems, Set);
            }

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_GACHA_ACTION_ACK))
            {
                oPacket.WriteInt(0);
                oPacket.WriteInt(CharID);
                oPacket.WriteInt(Gema);
                oPacket.WriteHexString("00 00 00 01 34 12 27 47 00 00 00 03 00 00 00 03 00 00 FF FF 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 00 00 00 00 00 01 8E 8E 00 00 00 01 34 12 24 65 00 00 00 3A 00 00 00 3A 00 02 00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 01");
                oPacket.WriteInt(SortedItem); //00 09 92 5A
                oPacket.WriteInt(1);
                oPacket.WriteInt(rndUID);     //34 12 27 70
                oPacket.WriteHexString("00 00 00 02 00 00 00 02");
                oPacket.WriteInt(Level);
                oPacket.WriteHexString("00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00");
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
                LogFactory.GetLog("GACHA ACTION").LogHex("", ip.ToArray());
            }
        }
Esempio n. 12
0
        public void NotifySHAFile(ClientSession cs)
        {
            using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_SHAFILENAME_LIST_ACK))
            {
                oPacket.WriteInt(0);
                oPacket.WriteInt(SHAFileList.Length);
                for (int i = 0; i <= SHAFileList.Length - 1; i++)
                {
                    oPacket.WriteInt(SHAFileList[i].Length * 2);
                    oPacket.WriteUnicodeString(SHAFileList[i]);
                }

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 13
0
        public void Depot_Char_tab(ClientSession cs, InPacket ip)
        {
            ushort test = ip.ReadUShort();

            CharIndex = ip.ReadInt();
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_DEPOT_CHAR_TAB_INFO_ACK))
            {
                LogFactory.GetLog("Gacha").LogInfo("CHARACTER: " + CharIndex);
                oPacket.WriteInt(5);
                oPacket.WriteByte(0);
                oPacket.WriteByte((byte)CharIndex);
                oPacket.WriteHexString("01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
                LogFactory.GetLog("DEPOT_CHAR").LogHex("", ip.ToArray());
            }
        }
Esempio n. 14
0
        public void Gacha_SET_Reward_List(ClientSession cs, InPacket ip)
        {
            int unk1   = ip.ReadInt();
            int itemID = ip.ReadInt();

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_GACHA_SET_REWARD_LIST_ACK))
            {
                oPacket.WriteInt(unk1);
                oPacket.WriteInt(itemID);
                oPacket.WriteHexString("01 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(Weapon[0]); //Weapon
                oPacket.WriteHexString("00 00 00 01 00 00 00 01");
                oPacket.WriteInt(Pet);       //PET
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 15
0
 public void GMCommands(ClientSession cs, String Chat, InPacket ip)
 {
     if (cs.AuthLevel == 1)
     {
         //Commands!
         if (Chat == "/loginout")
         {
             using (OutPacket op = new OutPacket(GameOpcodes.EVENT_STAT_LOGINOUT_COUNT))
             {
                 op.WriteInt(0);
                 op.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                 cs.Send(op);
             }
         }
         if (Chat == "/Char" + Chat.Substring(5))
         {
             cs.CurrentChar = Convert.ToInt32(Chat.Substring(5));
         }
         if (Chat == "/addgp" + (string)Chat.Substring(6))
         {
             DataSet ds = new DataSet();
             Database.Query(ref ds, "UPDATE   `gc`.`account` SET   `Gamepoint` = '{1}' WHERE `LoginUID` = '{0}'", cs.LoginUID, cs.GamePoint + Convert.ToInt32(Chat.Substring(6)));
         }
         if (Chat == "!!!!!" + Chat.Substring(5))
         {
             using (OutPacket op = new OutPacket(GameOpcodes.EVENT_SIGN_BOARD_NOT))
             {
                 //LogFactory.GetLog("SIGNBOARD").LogInfo("TEXT: " + Chat.Substring(5));
                 op.WriteHexString("00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                 op.WriteInt((cs.Nick + " : " + Chat.Substring(5)).Length * 2);
                 op.WriteUnicodeString((cs.Nick + " : " + Chat.Substring(5)));
                 foreach (ClientSession u in cs.CurrentChannel.UsersList)
                 {
                     if (u.CurrentRoom == cs.CurrentRoom)
                     {
                         op.Assemble(u.CRYPT_KEY, u.CRYPT_HMAC, u.CRYPT_PREFIX, u.CRYPT_COUNT);
                         u.Send(op);
                         op.CancelAssemble();
                     }
                 }
             }
         }
     }
 }
Esempio n. 16
0
        public void Gacha_Reward_List(ClientSession cs, InPacket ip)
        {
            int u1 = ip.ReadInt();

            Gem = ip.ReadInt();

            Weapon[0]  = 892300;
            Helm       = 546000; //Helm
            UpperArmor = 546010; //Upper Armor
            LowerArmor = 546020; //Lower Armor
            Gloves     = 546030; //Gloves
            Shoes      = 546040; //Shoes
            Cloak      = 546050; //Cloak
            Circlet    = 547240; //Circlet
            Wings      = 547260; //Wings
            Stompers   = 547280; //Stompers
            Shields    = 547270; //Shields
            Mask       = 547250; //Mask

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_GACHA_REWARD_LIST_ACK))
            {
                LogFactory.GetLog("Gacha").LogInfo("GEMA: " + Gem);
                oPacket.WriteInt(u1);
                oPacket.WriteInt(Gem);
                oPacket.WriteHexString("01 00 00 00 02 00 00 00 00");
                oPacket.WriteInt(6);//Length items
                oPacket.WriteInt(Helm);
                oPacket.WriteInt(UpperArmor);
                oPacket.WriteInt(LowerArmor);
                oPacket.WriteInt(Gloves);
                oPacket.WriteInt(Shoes);
                oPacket.WriteInt(Cloak);
                oPacket.WriteInt(1);
                oPacket.WriteInt(5);//Length Acessorios
                oPacket.WriteInt(Circlet);
                oPacket.WriteInt(Wings);
                oPacket.WriteInt(Stompers);
                oPacket.WriteInt(Shields);
                oPacket.WriteInt(Mask);
                oPacket.WriteHexString("00 00 00 06 00 00 00 1E 00 00 00 02 00 00 00 28 00 00 00 02 00 00 00 32 00 00 00 03 00 00 00 3C 00 00 00 03 00 00 00 46 00 00 00 04 00 00 00 50 00 00 00 05 00 00 00 00");
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 17
0
        public void NotifySHAFile(ClientSession cs, InPacket ip)
        {
            using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_SHAFILENAME_LIST_ACK))
            {
                oPacket.WriteInt(0);
                oPacket.WriteInt(SHAFileList.Length);
                for (int i = 0; i <= checklist.Length - 1; i++)
                {
                    oPacket.WriteInt(checklist[i].nFile.Length * 2);
                    oPacket.WriteUnicodeString(checklist[i].nFile);
                    oPacket.WriteInt(checklist[i].CRC.Length * 2);
                    oPacket.WriteUnicodeString(checklist[i].CRC);
                }

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
                LogFactory.GetLog("DATA").LogHex("PACKET: ", ip.ToArray());
            }
        }
Esempio n. 18
0
        public void OnChat(ClientSession cs, InPacket ip)
        {
            ip.ReadByte(); // 01
            ip.ReadInt();  // 00 00 00 00
            int    WhereLen = ip.ReadInt();
            string Where    = ip.ReadUnicodeString(WhereLen);

            ip.ReadInt(); // 00 00 00 00
            ip.ReadInt(); // 00 00 00 00
            ip.ReadInt(); // FF FF FF FF
            int    ChatLen = ip.ReadInt();
            string Chat    = ip.ReadUnicodeString(ChatLen);

            //LogFactory.GetLog("Main").LogInfo("Chat: {0}", Chat);

            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_CHAT_NOT))
            {
                op.WriteByte(1);
                op.WriteInt(cs.LoginUID);
                op.WriteInt(cs.Nick.Length * 2);
                op.WriteUnicodeString(cs.Nick);
                op.WriteInt(0);
                op.WriteInt(0);
                op.WriteInt(-1);
                op.WriteInt(ChatLen);
                op.WriteUnicodeString(Chat);
                op.WriteInt(0);
                op.WriteInt(0);

                // 채널에 있는 모든 유저중 같은 방 (null이면 로비실이니까.)
                foreach (ClientSession u in UsersList)
                {
                    if (u.CurrentRoom == cs.CurrentRoom)
                    {
                        op.Assemble(u.CRYPT_KEY, u.CRYPT_HMAC, u.CRYPT_PREFIX, u.CRYPT_COUNT);
                        u.Send(op);
                        op.CancelAssemble(); // 버퍼 되돌리기
                    }
                }
            }
        }
Esempio n. 19
0
        public void SendServerList(ClientSession cs)
        {
            /*string ServerName = Settings.GetString("GameServer/ServerName");
            *  string ServerDesc = Settings.GetString("GameServer/ServerDesc");
            *  string ServerIP = Settings.GetString("GameServer/ExternalIP");
            *  short ServerPort = Settings.GetShort("GameServer/Port");
            *
            *  string TestServerName = Settings.GetString("GameServerTest/ServerName");
            *  string TestServerDesc = Settings.GetString("GameServerTest/ServerDesc");
            *  string TestServerIP = Settings.GetString("GameServerTest/ExternalIP");
            *  short TestServerPort = Settings.GetShort("GameServerTest/Port");*/

            using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_SERVER_LIST_NOT))
            {
                LoadServerList();
                oPacket.WriteInt(serverlist.Length); // 서버 개수
                int i = 0;
                for (int j = 0; j < serverlist.Length; j++)
                {
                    oPacket.WriteInt(i + 1); // 서버 번호
                    oPacket.WriteInt(i + 1); // 서버 번호 2
                    oPacket.WriteInt(serverlist[j].ServerName.Length * 2);
                    oPacket.WriteUnicodeString(serverlist[j].ServerName);
                    oPacket.WriteInt(serverlist[j].ServerIP.Length);
                    oPacket.WriteString(serverlist[j].ServerIP);
                    oPacket.WriteShort((short)serverlist[j].ServerPort);
                    oPacket.WriteInt(serverlist[j].Users);           // 현재 접속중인 인원
                    oPacket.WriteInt(serverlist[j].MaxUsers);        // 최대 접속가능 인원
                    oPacket.WriteInt(serverlist[j].Flag);            //00 00 01 43 //323
                    oPacket.WriteHexString("FF FF FF FF FF FF FF FF");
                    oPacket.WriteInt(serverlist[j].ServerIP.Length); // 아이피를 또 보낸다.
                    oPacket.WriteString(serverlist[j].ServerIP);     // ㅄ
                    oPacket.WriteInt(serverlist[j].ServerDesc.Length * 2);
                    oPacket.WriteUnicodeString(serverlist[j].ServerDesc);
                    oPacket.WriteInt(serverlist[j].ServerType);
                }

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 20
0
        public void OnTrainSkill(ClientSession cs, InPacket ip)
        {
            // 스킬을 배운다. 일단은 그냥 배우게 허락한다.
            int SkillID = ip.ReadInt();

            // 배운 스킬 목록에 넣는다. (캐릭터 구분이 현재 불가능하므로 모든캐릭터에 넣어버린다...)
            for (int i = 0; i < MyChar.Length; i++)
            {
                Array.Resize(ref MyChar[i].MySkill, MyChar[i].MySkill.Length + 1);
                MyChar[i].MySkill[MyChar[i].MySkill.Length - 1].SkillID = SkillID;
            }

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_SKILL_TRAINING_ACK))
            {
                oPacket.WriteInt(0); // 성공 여부인가봄
                oPacket.WriteInt(SkillID);

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 21
0
        public void SquareList(ClientSession cs)
        {
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_SQUARE_LIST_ACK))
            {
                LogFactory.GetLog("MAIN").LogInfo("PLAYERS IN SQUARE: " + CurrentPlayers);
                ServerIP = Settings.GetString("Squares/ServerIP");

                oPacket.WriteInt(1);     //total de servers
                oPacket.WriteInt(1);
                oPacket.WriteInt(ServerName.Length * 2);
                oPacket.WriteUnicodeString(ServerName);
                oPacket.WriteInt(MaxPlayers);            //00 00 00 32
                oPacket.WriteInt(CurrentPlayers);        //00 00 00 02
                oPacket.WriteInt(0);                     //00 00 00 00
                oPacket.WriteIPFromString(Server.UDPRelayIP, true);
                oPacket.WriteShort(Server.TCPRelayPort); //2D 50 0C C6 25 E4
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(ServerIP.Length * 2);
                oPacket.WriteUnicodeString(ServerIP);
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 22
0
        public void create_pet(ClientSession cs, InPacket ip)
        {
            byte Bind   = ip.ReadByte();
            int  PetID  = ip.ReadInt();
            int  Evo    = ip.ReadInt();
            int  PetUID = ip.ReadInt();

            DataSet ds = new DataSet();

            Database.Query(ref ds, "INSERT INTO `gc`.`pet` (  `LoginUID`,  `PetItemID`,  `Exp`,  `Health`,  `Name`,  `Slot1`,  `Slot2`,  `Level`,  `Bind`,  `Evo`) VALUES  (    '{0}',    '{1}',    '0',    '0',    '',    '0',    '0',    '0',    '0',    '0'  )", cs.LoginUID, PetID);

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_CREATE_PET_ACK))
            {
                /*oPacket.WriteInt(0);
                 * oPacket.WriteByte(0xFF);
                 * oPacket.WriteInt(1);
                 * oPacket.WriteInt(PetUID);
                 * oPacket.WriteInt(PetID);*/
                oPacket.WriteHexString("00 00 00 00 FF 00 00 00 01 35 3C CC AB 00 02 E4 82 00 00 00 1A 53 00 71 00 75 00 69 00 72 00 65 00 20 00 47 00 61 00 69 00 6B 00 6F 00 7A 00 00 00 00 03 00 00 00 00 64 01 00 00 00 64 02 00 00 00 64 00 00 00 64 00 00 00 00 00 FF FF FF FF 00 00 03 E8 00 00 03 E8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00 02 E4 8C 00 00 00 01 35 3C CC BF 00 00 00 64 00 00 00 64 00 00 FF FF 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00");
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 23
0
        public void setSkill(ClientSession cs, InPacket ip)
        {
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_SKILL_TRAINING_ACK))
            {
                skillid = ip.ReadInt();
                oPacket.WriteInt(0);
                oPacket.WriteInt(skillid);
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);

                /*Database.Query(ref ds, "SELECT  `skillID` FROM  `skilltree`", cs.LoginUID,cs.Login);
                 * skill2 = Convert.ToInt32(ds.Tables[0].Rows[0]["skillID"].ToString());
                 * if (skill2 == skillid)
                 * {
                 *  return;
                 * }
                 * else
                 * {*/
                DataSet ds2 = new DataSet();
                Database.Query(ref ds2, "INSERT INTO `skilltree` (`LoginUID`, `Login`, `skillID`) VALUES  ('{0}', '{1}', '{2}')", cs.LoginUID, cs.Login, skillid);
                //}
            }
        }
Esempio n. 24
0
        public void FriendList(ClientSession msg, InPacket ip)
        {
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_INVITE_NOT))
            {
                msg.LoginUID = ip.ReadInt();
                int LenLogin = ip.ReadInt();
                msg.Login = ip.ReadUnicodeString(LenLogin);

                LogFactory.GetLog("MSG INFOS").LogInfo("LoginUID: " + msg.LoginUID);
                LogFactory.GetLog("MSG INFOS").LogInfo("Length Lgn: " + LenLogin);
                LogFactory.GetLog("MSG INFOS").LogInfo("Login: "******"00 00 00 00 00 00 00 01 00 00 00 0A 00 00 00 0A 00 00 00 0C 46 00 72 00 69 00 65 00 6E 00 64 00");
                oPacket.WriteInt(listfriends.Length);
                LogFactory.GetLog("FriendsList").LogInfo("List Length: " + listfriends.Length);
                for (int z = 0; z < listfriends.Length; z++)
                {
                    LogFactory.GetLog("FriendsList").LogInfo("FriendName: " + listfriends[z].FriendName);
                    oPacket.WriteInt(listfriends[z].FriendID);
                    oPacket.WriteInt(listfriends[z].FriendID);
                    oPacket.WriteInt(listfriends[z].FriendName.Length * 2);
                    oPacket.WriteUnicodeString(listfriends[z].FriendName);
                    oPacket.WriteHexString("00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 FF FF FF FF");//00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 FF FF FF FF
                }
                oPacket.WriteHexString("00 00 00 01 00 00 00 18 42 00 6C 00 6F 00 63 00 6B 00 20 00 46 00 72 00 69 00 65 00 6E 00 64 00 00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.Assemble(msg.CRYPT_KEY, msg.CRYPT_HMAC, msg.CRYPT_PREFIX, ++msg.CRYPT_COUNT);
                msg.Send(oPacket);
            }
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_CHANGE_ROOMUSER_INFO_REQ))
            {
                oPacket.WriteHexString("00 00 00 01 00 00 00 0A 00 00 00 00");
                oPacket.CompressAndAssemble(msg.CRYPT_KEY, msg.CRYPT_HMAC, msg.CRYPT_PREFIX, ++msg.CRYPT_COUNT);
                msg.Send(oPacket);
            }
        }
Esempio n. 25
0
        public void enterSquare(ClientSession cs)
        {
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ENTER_SQUARE_ACK))
            {
                PlayersList.Add(cs);
                oPacket.WriteInt(0);              //00 00 00 00
                oPacket.WriteInt(CurrentPlayers); //00 00 00 04

                /*for (int i = 0; i < CurrentPlayers; i++)
                 * {
                 *  oPacket.WriteInt(1);//00 00 00 01
                 *  oPacket.WriteInt(4);//00 00 00 04
                 *  oPacket.WriteInt(1273);//00 00 04 F9
                 *  oPacket.WriteInt("1273_1.png".Length * 2);//00 00 00 14
                 *  oPacket.WriteUnicodeString("1273_1.png");//31 00 32 00 37 00 33 00 5F 00 31 00 2E 00 70 00 6E 00 67 00
                 *  oPacket.WriteInt("BrokenLimit".Length * 2);//00 00 00 16
                 *  oPacket.WriteUnicodeString("BrokenLimit");//42 00 72 00 6F 00 6B 00 65 00 6E 00 4C 00 69 00 6D 00 69 00 74 00
                 *  oPacket.WriteInt(cs.LoginUID);//00 01 59 58
                 *  oPacket.WriteInt(cs.Nick.Length * 2);//00 00 00 08
                 *  oPacket.WriteUnicodeString(cs.Nick);//41 00 6C 00 79 00 73 00
                 *  oPacket.WriteByte(4);//04 //CharID
                 *  oPacket.WriteInt(1);//00 00 00 01
                 *  oPacket.WriteInt(7);//Length Equips
                 *  for (int j = 0; j < 7; j++)
                 *  {
                 *      oPacket.WriteInt(380070);//itemID
                 *  }
                 *  oPacket.WriteHexString("00 00 00 0D 00 00 00 00 00 00 00 01 40 F1 99 9A 3E 8A 3D 71 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 12 C8 F2 00 00 E5 74 00 01 BD E6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                 * }*/

                foreach (ClientSession u in PlayersList)
                {
                    oPacket.WriteInt(1);                               //00 00 00 01
                    oPacket.WriteInt(4);                               //00 00 00 04
                    oPacket.WriteInt(u.MyGuilds.GuildID);              //00 00 04 F9
                    oPacket.WriteInt(u.MyGuilds.MarkName.Length * 2);  //00 00 00 14
                    oPacket.WriteUnicodeString(u.MyGuilds.MarkName);   //31 00 32 00 37 00 33 00 5F 00 31 00 2E 00 70 00 6E 00 67 00
                    oPacket.WriteInt(u.MyGuilds.GuildName.Length * 2); //00 00 00 16
                    oPacket.WriteUnicodeString(u.MyGuilds.GuildName);  //42 00 72 00 6F 00 6B 00 65 00 6E 00 4C 00 69 00 6D 00 69 00 74 00
                    oPacket.WriteInt(u.LoginUID);                      //00 01 59 58
                    oPacket.WriteInt(u.Nick.Length * 2);               //00 00 00 08
                    oPacket.WriteUnicodeString(u.Nick);                //41 00 6C 00 79 00 73 00
                    int MyCharPos = -1;
                    for (int t = 0; t < u.MyCharacter.MyChar.Length; t++)
                    {
                        if (u.MyCharacter.MyChar[t].CharType == u.CurrentChar)
                        {
                            MyCharPos = t;
                        }
                    }
                    oPacket.WriteByte((byte)u.MyCharacter.MyChar[MyCharPos].CharType);                    //0F//CharID

                    /*oPacket.WriteByte((byte)u.CurrentChar);//0F//CharID
                     * //oPacket.WriteInt(0);//Equips
                     * int MyCharPos = -1;
                     * for (int t = 0; t < cs.MyCharacter.MyChar.Length; t++)
                     *  if (cs.MyCharacter.MyChar[t].CharType == u.CurrentChar)
                     *      MyCharPos = t;*/
                    oPacket.WriteInt(u.MyCharacter.MyChar[MyCharPos].Level);//00 00 00 01//Level
                    oPacket.WriteInt(u.MyCharacter.MyChar[MyCharPos].Equip.Length);
                    for (int y = 0; y < u.MyCharacter.MyChar[MyCharPos].Equip.Length; y++)
                    {
                        oPacket.WriteInt(u.MyCharacter.MyChar[MyCharPos].Equip[y].ItemID);
                    }
                    //oPacket.WriteHexString("00 00 00 03 00 0D 1D D0 00 0D 1D DA 00 0D 1D E4");
                    oPacket.WriteHexString("00 00 00 04 00 00 00 00 00 00 00 01 40 F1 99 9A 3E 8A 3D 71 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 12 C8 F2 00 00 E5 74 00 01 BD E6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                    //("00 00 00 04 00 00 00 00 00 00 00 01 41 14 00 00 3E 8A 3D 71 02 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 E5 6A 00 00 E5 88 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 06 00 00 13 FB 00 00 00 1E 64 00 65 00 66 00 61 00 75 00 6C 00 74 00 6D 00 61 00 72 00 6B 00 2E 00 70 00 6E 00 67 00 00 00 00 14 45 00 6C 00 69 00 74 00 65 00 4D 00 61 00 66 00 69 00 61 00 00 05 F1 A4 00 00 00 16 42 00 72 00 61 00 69 00 6E 00 4D 00 61 00 73 00 74 00 65 00 72 00 0E 00 00 00 4F 00 00 00 20 00 07 DF 6E 00 0C 43 EC 00 0A E2 4A 00 0A DD C2 00 0A DC F0 00 0A DC FA 00 0A D0 52 00 0A D0 3E 00 0A D0 66 00 0A D0 5C 00 0A D0 48 00 0A D0 70 00 0A DD 72 00 12 4C 24 00 0A DD 36 00 0A DB 06 00 12 4C 2E 00 12 4C 38 00 12 4C 10 00 12 4C 1A 00 12 4C 42 00 12 56 B0 00 0A DD 7C 00 12 56 CE 00 12 4E D6 00 0A DE 1C 00 12 56 A6 00 10 5D BA 00 10 57 16 00 0A DE 12 00 12 56 C4 00 05 0F 6E 00 00 00 04 00 00 00 00 00 00 00 01 40 F1 99 9A 3E 8A 3D 71 0B 00 00 00 00 00 00 13 AF EC 00 00 00 10 50 00 72 00 69 00 6E 00 73 00 69 00 6F 00 6E 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 04 00 12 C8 F2 00 00 E5 74 00 01 BD F0 00 01 BE 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 13 E6 CE 00 00 00 01 31 FD D9 2D 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E6 D8 00 00 00 01 31 FD D9 2E 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E6 E2 00 00 00 01 31 FD D9 2F 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E6 EC 00 00 00 01 31 FD D9 30 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E8 22 00 00 00 01 31 FD D9 31 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 4A 00 00 00 01 31 FD D9 C0 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 54 00 00 00 01 31 FD D9 C1 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 5E 00 00 00 01 31 FD D9 C2 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 68 00 00 00 01 31 FD D9 C3 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 72 00 00 00 01 31 FD D9 C4 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 E3 7C 00 00 00 01 31 FD D9 C5 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03");
                }
                oPacket.WriteIPFromString(Server.TCPRelayIP, true);
                oPacket.WriteShort(Server.TCPRelayPort);//2D 50 0C C6 25 E4
                oPacket.WriteHexString("00 00 00 00 00 00 00 01 41 14 00 00 3E 8A 3D 71");
                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 26
0
        public void OnRoomList(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte();

            //LogFactory.GetLog("Main").LogInfo("RoomTYPE: " + RoomType);

            // 그 뒤로
            // FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
            // 어딘가에 페이지가 있겠다.

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                int roomcount = 0;//default is 0
                //LogFactory.GetLog("Main").LogInfo("HUEHUE ROOMS Count: " + roomcount);
                foreach (Room room in RoomsList)
                {
                    // 대기방만 보여주는 것이라면...
                    if (RoomType == 1)
                    {
                        // 게임시작이거나, 남는자리가 없다면 생략
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                }
                oPacket.WriteInt(roomcount);
                for (int j = 0; j < roomcount; j++)
                {
                    /*ushort roomid = 38;//00 26
                    *  string nameRoom = "test";
                    *  string passRoom = "";//01
                    *  ushort fresslots = 4;
                    *  ushort players = 1;
                    *  bool playing = false;
                    *  string nick = "[ADM]Hiro";*/

                    //Room room = new Room();

                    /*
                     * oPacket.WriteUShort(1);//00 26
                     * oPacket.WriteInt("Vamos jogar!".Length * 2);//00 00 00 0C
                     * oPacket.WriteUnicodeString("Vamos jogar!");//68 BE AC B9 68 BE AC B9 21 00 21 00
                     * oPacket.WriteByte(1);
                     * oPacket.WriteByte(0);//00
                     * oPacket.WriteInt("".Length * 2);//00 00 00 00
                     * oPacket.WriteUnicodeString("");
                     * oPacket.WriteUShort(4);//00 04
                     * oPacket.WriteUShort(1);//00 01
                     * oPacket.WriteBool(false);//00
                     * oPacket.WriteHexString("28 5C DA F2 02 02 00 00 00 08 32 25 A5 77 00 00 00 03 00 00 00 00 00 00 00 01");
                     * oPacket.WriteInt("[ADM]SkelletonX".Length * 2);
                     * oPacket.WriteUnicodeString("[ADM]SkelletonX");
                     * oPacket.WriteHexString("02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 01");
                     */
                    foreach (Room room in RoomsList)
                    {
                        ushort roomid    = room.ID;       //00 26
                        string nameRoom  = room.RoomName;
                        string passRoom  = room.RoomPass; //01
                        ushort fresslots = 4;
                        ushort players   = (ushort)room.GetPlayerCount();
                        bool   playing   = room.Playing;
                        string nick      = room.GetRoomLeaderCS().Nick;

                        //LogFactory.GetLog("Main").LogInfo("roomID: " + roomid);
                        //LogFactory.GetLog("Main").LogInfo("Name Room: " + nameRoom);
                        //LogFactory.GetLog("Main").LogInfo("Pass Room: " + passRoom);
                        //LogFactory.GetLog("Main").LogInfo("Slots: " + fresslots);
                        //LogFactory.GetLog("Main").LogInfo("players: " + players);
                        //LogFactory.GetLog("Main").LogInfo("Playing: " + playing);

                        if (RoomType == 1)
                        {
                            if (room.Playing == true || room.GetFreeSlot() == 0)
                            {
                                continue;
                            }
                        }
                        oPacket.WriteUShort(roomid);           //00 26
                        oPacket.WriteInt(nameRoom.Length * 2); //00 00 00 0C
                        oPacket.WriteUnicodeString(nameRoom);  //68 BE AC B9 68 BE AC B9 21 00 21 00
                        if (passRoom.Length > 0)               //01
                        {
                            oPacket.WriteByte(0);
                        }
                        else
                        {
                            oPacket.WriteByte(1);
                        }
                        oPacket.WriteByte(0);                  //00
                        oPacket.WriteInt(passRoom.Length * 2); //00 00 00 00
                        oPacket.WriteUnicodeString(passRoom);
                        oPacket.WriteUShort(fresslots);        //00 04
                        oPacket.WriteUShort(players);          //00 01
                        oPacket.WriteBool(playing);            //00
                        oPacket.WriteHexString("28 5C DA F2 02 02 00 00 00 08 32 25 A5 77 00 00 00 03 00 00 00 00 00 00 00 01");
                        oPacket.WriteInt(nick.Length * 2);
                        oPacket.WriteUnicodeString(nick);
                        oPacket.WriteHexString("02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 01");
                    }
                }
                //}

                /* 방 정보 조합
                 * foreach (Room room in RoomsList)
                 * {
                 *  // 대기방만 보여주는 것이라면...
                 *  if( RoomType == 1 )
                 *  {
                 *      // 게임시작이거나, 남는자리가 없다면 생략
                 *      if (room.Playing == true || room.GetFreeSlot() == 0)
                 *          continue;
                 *  }
                 *
                 *  oPacket.WriteUShort(1);
                 *  oPacket.WriteInt("kkk".Length * 2);
                 *  oPacket.WriteUnicodeString("kkk");
                 *
                 *  if (room.RoomPass.Length > 0)
                 *      oPacket.WriteByte(0); // 비밀방
                 *  else
                 *      oPacket.WriteByte(1); // 공개방
                 *  oPacket.WriteByte(0);
                 *  oPacket.WriteInt("hue".Length * 2);
                 *  oPacket.WriteUnicodeString("hue");
                 *  //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);
                 *
                 *  // 빈자리 + 유저수 = 총 자리 개수
                 *  oPacket.WriteShort(3 + 1);
                 *  //LogFactory.GetLog("Main").LogInfo(3);
                 *  oPacket.WriteShort(1);
                 *  //LogFactory.GetLog("Main").LogInfo(1);
                 *  oPacket.WriteBool(false);
                 *  //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);
                 *
                 *  oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");
                 *
                 *  oPacket.WriteInt("[ADM]SkelletonX".Length * 2);
                 *  //LogFactory.GetLog("Main").LogInfo("LEADER NICK: " + room.GetRoomLeaderCS().Nick);
                 *  oPacket.WriteUnicodeString("[ADM]SkelletonX");
                 *
                 *  oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                 * }*/

                // 여태껏 조합된 방 정보를 압축한다.
                int RoomInfoSize = oPacket.ToArray().Length; // 압축하기 전 사이즈
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer(); // 초기화

                // 실제 패킷 작성
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);                   // 압축된 정보크기 + 4(실제 크기버퍼)
                oPacket.WriteByte(1);                                    // 압축된 데이터다.
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize)); // 압축전 사이즈를 일반적으로 넣는다.
                oPacket.WriteBytes(RoomInfo);                            // 압축된 방 정보

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
                //LogFactory.GetLog("Main").LogHex("ROOMLIST: ", oPacket.getBuffer());
            }
        }
Esempio n. 27
0
        public void OnRoomList(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte();


            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                int roomcount = 0;
                foreach (Room room in RoomsList)
                {
                    if (RoomType == 1)
                    {
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                }
                oPacket.WriteInt(roomcount);

                foreach (Room room in RoomsList)
                {
                    if (RoomType == 1)
                    {
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }

                    oPacket.WriteUShort(room.ID);
                    oPacket.WriteInt(room.RoomName.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomName);

                    if (room.RoomPass.Length > 0)
                    {
                        oPacket.WriteByte(0);
                    }
                    else
                    {
                        oPacket.WriteByte(1);
                    }
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(room.RoomPass.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomPass);

                    oPacket.WriteShort((short)(room.GetFreeSlot() + room.GetPlayerCount()));
                    oPacket.WriteShort((short)room.GetPlayerCount());
                    oPacket.WriteBool(room.Playing);

                    oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");

                    oPacket.WriteInt(room.GetRoomLeaderCS().Nick.Length * 2);
                    oPacket.WriteUnicodeString(room.GetRoomLeaderCS().Nick);

                    oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                }


                int RoomInfoSize = oPacket.ToArray().Length;
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer();

                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);
                oPacket.WriteByte(1);
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize));
                oPacket.WriteBytes(RoomInfo);

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Esempio n. 28
0
        public void OnJoinRoom(ClientSession cs, InPacket ip)
        {
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ushort RoomID  = ip.ReadUShort();
            int    PassLen = ip.ReadInt();
            string Pass    = "";

            if (PassLen > 0)
            {
                Pass = ip.ReadUnicodeString(PassLen);
            }
            //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM ID: "+RoomID);
            //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Length Password: "******"ROOM INFO:").LogInfo("ROOM Password: "******"Main").LogInfo(" Sergio Dean {0} metade Kana {1} {2} uma determinada ranhura ({3}, {4})", Team1, Team2, pos, EmptyPos1, EmptyPos2);

            // 방 슬롯에 정보 입력
            room.Slot[pos].Active = true;
            room.Slot[pos].cs     = cs;
            room.Slot[pos].Open   = false;
            room.Slot[pos].Spree  = 0;
            room.Slot[pos].Leader = false;
            room.Slot[pos].AFK    = false;

            // 유저한테 방 입력
            cs.CurrentRoom = room;

            // 방에 있는 사람들한테 입장했다고 알려준다. (입장하는놈은 제외)
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length * 2);
                oPacket.WriteUnicodeString(cs.Login);
                oPacket.WriteInt(cs.LoginUID);
                oPacket.WriteInt(cs.Nick.Length * 2);
                oPacket.WriteUnicodeString(cs.Nick);
                oPacket.WriteInt(pos);
                oPacket.WriteByte((byte)cs.CurrentChar);
                oPacket.WriteHexString("00 FF 00 FF 00 FF 00 00 00 00");
                oPacket.WriteByte((byte)(pos / 3)); // 팀을 구하면 됨. 빠르게 처리하기 위해서
                oPacket.WriteHexString("01 00 00 00 0D 00 00 00 00 10 F4 00 00 00 00 00 4E 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 00 00 00 00 00 00 00 00 00 00 00");
                if (room.GetRoomLeaderCS() == cs)
                {
                    oPacket.WriteByte(1);
                }
                else
                {
                    oPacket.WriteByte(0);
                }
                oPacket.WriteHexString("01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                oPacket.WriteByte((byte)cs.MyCharacter.MyChar.Length);
                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Promotion);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].Promotion);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Exp);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].Exp);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Level);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].Level);
                    oPacket.WriteInt(0);
                    oPacket.WriteInt(0);

                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                    }

                    //oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00 00 00 00 00 00 00 00 02 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 01 FF 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
                    // 이 패킷이 아래 끝까지 분리됐음. ▼▼
                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00");

                    // 장착한 스킬

                    /*
                     * oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].EquipSkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(0);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillGroup);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);

                    // FF가 스킬포인트일지도
                    oPacket.WriteHexString("00 00 00 FF 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 FF 00 00 00 00 00 00");

                    // 배운 스킬

                    /*oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].MySkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);

                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
                    // ▲▲
                }
                oPacket.WriteHexString("00 00 00 04 13 00 A8 C0 01 EC A8 C0 9B BA FE A9");
                oPacket.WriteIPFromString(cs.GetIP(), false);
                oPacket.WriteHexString("00 00 00 01 7E F6 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 E5 6A 00 00 00 01 2C BD 52 5A 00 00 00 00 01 00 00 E5 88 00 00 00 01 2C BD 52 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 56 86 32 00 56 87 6E D4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                // 방에 있는 모든 유저에게 전송해야함.
                for (int i = 0; i < 6; i++)
                {
                    // 나 자신은 제외한 나머지한테 전송
                    if (room.Slot[i].Active == true && room.Slot[i].cs != cs)
                    {
                        oPacket.Assemble(room.Slot[i].cs.CRYPT_KEY, room.Slot[i].cs.CRYPT_HMAC, room.Slot[i].cs.CRYPT_PREFIX, room.Slot[i].cs.CRYPT_COUNT);
                        room.Slot[i].cs.Send(oPacket); // 패킷 보내고
                        oPacket.CancelAssemble();      // 다시 패킷 복구
                    }
                }
            }

            // 방에 접속했다고 알려준다.
            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_ACK))
            {
                op.WriteUShort(RoomID);
                op.WriteInt(room.RoomName.Length * 2);
                op.WriteUnicodeString(room.RoomName);
                op.WriteByte(0);
                if (room.RoomPass.Length > 0)
                {
                    op.WriteByte(1); // 비밀방
                }
                else
                {
                    op.WriteByte(0); // 공개방
                }
                op.WriteInt(room.RoomPass.Length * 2);
                op.WriteUnicodeString(room.RoomPass);
                op.WriteShort((short)room.GetPlayerCount());
                op.WriteShort((short)room.GetFreeSlot());
                op.WriteHexString("00 0B");
                op.WriteByte((byte)room.GameCategory);
                op.WriteInt(room.GameMode);
                op.WriteInt(room.ItemMode);
                op.WriteBool(room.RandomMap);
                op.WriteInt(room.GameMap);
                op.WriteHexString("00 00 00 0C");
                for (int i = 0; i < 6; i++)
                {
                    op.WriteBool(room.Slot[i].Open);
                }
                op.WriteHexString("FF FF FF FF 00 00 00 00 00 00 00 00 01");
                op.WriteIPFromString(Server.UDPRelayIP, true);
                op.WriteShort(Server.UDPRelayPort);
                op.WriteIPFromString(Server.TCPRelayIP, true);
                op.WriteShort(Server.TCPRelayPort);

                op.WriteHexString("01 00 01 00 00 01 2C 00 00 00 14 00 02 4B 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 01 00 00 00 00");

                op.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }

            room.SendJoinRoomInfoDivide(cs);
            //return;

            // 방에 입장할 수 없다.
cantjoin:
            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_DIVIDE_ACK))
            {
                op.WriteInt(6);
                op.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 30 00 00 00 F9 00 00 09 0D 00 00 00 00 00 00 00 00 F2 04 00 00 00 00 00 00 13 49 F4 FC 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 09 13 F2 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                op.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }
            //return;
        }
Esempio n. 29
0
        public void OnRoomList2(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte(); // 1 = 대기방보기, 0 = 모든방보기

            //LogFactory.GetLog("Main").LogInfo("RoomTYPE: " + RoomType);

            // 그 뒤로
            // FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
            // 어딘가에 페이지가 있겠다.

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                // 방 정보를 조합한 다음에 압축하고, 실제 패킷을 작성한다.

                // 방 개수 구하기
                int roomcount = 0;

                //LogFactory.GetLog("Main").LogInfo("ROOMS Count: " + roomcount);

                foreach (Room room in RoomsList)
                {
                    //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);
                    //LogFactory.GetLog("Main").LogInfo("Slots: " + room.GetFreeSlot());
                    //LogFactory.GetLog("Main").LogInfo("Players: " + room.GetPlayerCount());
                    //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);
                    // 대기방만 보여주는 것이라면...
                    if (RoomType == 1)
                    {
                        // 게임시작이거나, 남는자리가 없다면 생략
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                    //LogFactory.GetLog("Main").LogInfo("Rooms: " + roomcount);
                }
                oPacket.WriteInt(roomcount);

                // 방 정보 조합
                foreach (Room room in RoomsList)
                {
                    // 대기방만 보여주는 것이라면...

                    /*if (RoomType == 1)
                     * {
                     *  // 게임시작이거나, 남는자리가 없다면 생략
                     *  if (room.Playing == true || room.GetFreeSlot() == 0)
                     *      continue;
                     * }
                     */
                    oPacket.WriteUShort(room.ID);
                    oPacket.WriteInt(room.RoomName.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomName);

                    if (room.RoomPass.Length > 0)
                    {
                        oPacket.WriteByte(0); // 비밀방
                    }
                    else
                    {
                        oPacket.WriteByte(1); // 공개방
                    }
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(room.RoomPass.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomPass);
                    //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);

                    // 빈자리 + 유저수 = 총 자리 개수
                    oPacket.WriteShort((short)(room.GetFreeSlot() + room.GetPlayerCount()));
                    //LogFactory.GetLog("Main").LogInfo("Slots: " + room.GetFreeSlot());
                    oPacket.WriteShort((short)room.GetPlayerCount());
                    //LogFactory.GetLog("Main").LogInfo("Players: " + room.GetPlayerCount());
                    oPacket.WriteBool(room.Playing);
                    //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);

                    oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");

                    oPacket.WriteInt(room.GetRoomLeaderCS().Nick.Length * 2);
                    //LogFactory.GetLog("Main").LogInfo("LEADER NICK: " + room.GetRoomLeaderCS().Nick);
                    oPacket.WriteUnicodeString(room.GetRoomLeaderCS().Nick);

                    oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                }

                // 여태껏 조합된 방 정보를 압축한다.
                int RoomInfoSize = oPacket.ToArray().Length; // 압축하기 전 사이즈
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer(); // 초기화

                // 실제 패킷 작성
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);                   // 압축된 정보크기 + 4(실제 크기버퍼)
                oPacket.WriteByte(1);                                    // 압축된 데이터다.
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize)); // 압축전 사이즈를 일반적으로 넣는다.
                oPacket.WriteBytes(RoomInfo);                            // 압축된 방 정보

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
                //LogFactory.GetLog("Main").LogHex("ROOMLIST: ", oPacket.getBuffer());
            }
        }
Esempio n. 30
0
        public void OnJoinRoom(ClientSession cs, InPacket ip)
        {
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ushort RoomID  = ip.ReadUShort();
            int    PassLen = ip.ReadInt();
            string Pass    = "";

            if (PassLen > 0)
            {
                Pass = ip.ReadUnicodeString(PassLen);
            }


            Room room = GetRoom(RoomID);


            if (room == null)
            {
                goto cantjoin;
            }


            if (room.GetFreeSlot() == 0 || room.Playing == true || cs.CurrentRoom != null)
            {
                goto cantjoin;
            }


            if (room.RoomPass != Pass)
            {
                goto cantjoin;
            }


            byte Team1 = 0, Team2 = 0;
            int  EmptyPos1 = -1, EmptyPos2 = -1;

            for (int i = 0; i < 3; i++)
            {
                if (room.Slot[i].Active == true)
                {
                    Team1++;
                }
                if (EmptyPos1 == -1 && room.Slot[i].Open == true)
                {
                    EmptyPos1 = i;
                }
            }
            for (int i = 3; i < 6; i++)
            {
                if (room.Slot[i].Active == true)
                {
                    Team2++;
                }
                if (EmptyPos2 == -1 && room.Slot[i].Open == true)
                {
                    EmptyPos2 = i;
                }
            }


            int pos = EmptyPos1;

            if (Team1 >= Team2)
            {
                pos = EmptyPos2;
            }

            room.Slot[pos].Active = true;
            room.Slot[pos].cs     = cs;
            room.Slot[pos].Open   = false;
            room.Slot[pos].Spree  = 0;
            room.Slot[pos].Leader = false;
            room.Slot[pos].AFK    = false;


            cs.CurrentRoom = room;


            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length * 2);
                oPacket.WriteUnicodeString(cs.Login);
                oPacket.WriteInt(cs.LoginUID);
                oPacket.WriteInt(cs.Nick.Length * 2);
                oPacket.WriteUnicodeString(cs.Nick);
                oPacket.WriteInt(pos);
                oPacket.WriteByte((byte)cs.CurrentChar);
                oPacket.WriteHexString("00 FF 00 FF 00 FF 00 00 00 00");
                oPacket.WriteByte((byte)(pos / 3));
                oPacket.WriteHexString("01 00 00 00 0D 00 00 00 00 10 F4 00 00 00 00 00 4E 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 00 00 00 00 00 00 00 00 00 00 00");
                if (room.GetRoomLeaderCS() == cs)
                {
                    oPacket.WriteByte(1);
                }
                else
                {
                    oPacket.WriteByte(0);
                }
                oPacket.WriteHexString("01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                oPacket.WriteByte((byte)cs.MyCharacter.MyChar.Length);
                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Promotion);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Exp);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Level);
                    oPacket.WriteInt(0);
                    oPacket.WriteInt(0);

                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                    }

                    //oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00 00 00 00 00 00 00 00 02 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 01 FF 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");

                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00");


                    /*
                     * oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].EquipSkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(0);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillGroup);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);


                    oPacket.WriteHexString("00 00 00 FF 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 FF 00 00 00 00 00 00");


                    /*oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].MySkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);

                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
                }
                oPacket.WriteHexString("00 00 00 04 13 00 A8 C0 01 EC A8 C0 9B BA FE A9");
                oPacket.WriteIPFromString(cs.GetIP(), false);
                oPacket.WriteHexString("00 00 00 01 7E F6 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 E5 6A 00 00 00 01 2C BD 52 5A 00 00 00 00 01 00 00 E5 88 00 00 00 01 2C BD 52 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 56 86 32 00 56 87 6E D4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");


                for (int i = 0; i < 6; i++)
                {
                    if (room.Slot[i].Active == true && room.Slot[i].cs != cs)
                    {
                        oPacket.Assemble(room.Slot[i].cs.CRYPT_KEY, room.Slot[i].cs.CRYPT_HMAC, room.Slot[i].cs.CRYPT_PREFIX, room.Slot[i].cs.CRYPT_COUNT);
                        room.Slot[i].cs.Send(oPacket);
                        oPacket.CancelAssemble();
                    }
                }
            }


            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_ACK))
            {
                op.WriteUShort(RoomID);
                op.WriteInt(room.RoomName.Length * 2);
                op.WriteUnicodeString(room.RoomName);
                op.WriteByte(0);
                if (room.RoomPass.Length > 0)
                {
                    op.WriteByte(1);
                }
                else
                {
                    op.WriteByte(0);
                }
                op.WriteInt(room.RoomPass.Length * 2);
                op.WriteUnicodeString(room.RoomPass);
                op.WriteShort((short)room.GetPlayerCount());
                op.WriteShort((short)room.GetFreeSlot());
                op.WriteHexString("00 0B");
                op.WriteByte((byte)room.GameCategory);
                op.WriteInt(room.GameMode);
                op.WriteInt(room.ItemMode);
                op.WriteBool(room.RandomMap);
                op.WriteInt(room.GameMap);
                op.WriteHexString("00 00 00 0C");
                for (int i = 0; i < 6; i++)
                {
                    op.WriteBool(room.Slot[i].Open);
                }
                op.WriteHexString("FF FF FF FF 00 00 00 00 00 00 00 00 01");
                op.WriteIPFromString(Server.UDPRelayIP, true);
                op.WriteShort(Server.UDPRelayPort);
                op.WriteIPFromString(Server.TCPRelayIP, true);
                op.WriteShort(Server.TCPRelayPort);

                op.WriteHexString("01 00 01 00 00 01 2C 00 00 00 14 00 02 4B 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 01 00 00 00 00");

                op.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }

            room.SendJoinRoomInfoDivide(cs);
            return;


cantjoin:
            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_DIVIDE_ACK))
            {
                op.WriteInt(6);
                op.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 30 00 00 00 F9 00 00 09 0D 00 00 00 00 00 00 00 00 F2 04 00 00 00 00 00 00 13 49 F4 FC 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 09 13 F2 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                op.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }
            return;
        }