Beispiel #1
0
        /// <summary>
        /// Lets the server know that you want the character list
        /// </summary>
        /// <returns>Nothing</returns>
        private PacketOut CreateCharacterListPacket()
        {
            PacketOut o = new PacketOut(2001);

            o.FillString(m_szAccount, 61);
            o.FinalizeLengthAndChecksum();
            return(o);
        }
Beispiel #2
0
        private PacketOut CreateVersionPacket()
        {
            PacketOut o = new PacketOut(51);

            o.FillString("200701120", 20);
            o.FinalizeLengthAndChecksum();
            return(o);
        }
Beispiel #3
0
        public PacketIn ProcessPacket(TCPConnection con, byte[] buf, int start, int size)
        {
            PacketIn packet = new PacketIn(buf, start, size);

            switch (packet.ID)
            {
            case 72:     // TS_AC_AES_KEY_IV
                var pAES = new AUTH_PACKETS.AES_KEY_IV(packet);
                m_pAES_KEY = m_cRSA.PrivateDecrypt(pAES.nKey, OpenSSL.Crypto.RSA.Padding.PKCS1);
                GenerateLoginPacket(m_pAES_KEY, con);
                break;

            case 10000:     // TS_AC_RESULT
                var pResult = new AUTH_PACKETS.RESULT(packet.ReadUInt16(), packet.ReadUInt16(), packet.ReadInt32());
                if (pResult.nLoginFlag == 1)
                {
                    PacketOut o = new PacketOut(10021);
                    con.SendTCP(o);
                }
                else
                {
                    m_cAuthConnection.Disconnect();
                    XLog.Log("Login failed. Result: {0} - Disconnecting...", pResult.nResult);
                }
                m_szPassword = string.Empty;
                break;

            case 10022:     // TS_AC_SERVER_LIST
                m_iAuthServerList = new AUTH_PACKETS.SERVER_LIST(packet);
                XLog.Log("Server selection. Please use /select ID to connect to one of the listed servers below.");
                for (int i = 0; i < m_iAuthServerList.count; i++)
                {
                    XLog.Log(string.Format("-> Server {0}: {1}", i + 1, m_iAuthServerList.list[i].server_name));
                }
                break;

            case 10024:     // TS_AC_SELECT_SERVER
                con.Disconnect();

                var pSelectServer = new AUTH_PACKETS.SELECT_SERVER(packet, ref m_pAES_KEY);

                Config.ConfigNet conf = new Config.ConfigNet();
                conf.Port     = m_iAuthServerList.list[m_nSelectedServerIdx].server_port;
                conf.ListenIp = System.Net.IPAddress.Parse(m_iAuthServerList.list[m_nSelectedServerIdx].server_ip);

                PacketOut oEncrypt = new PacketOut(2005);
                oEncrypt.FillString(m_szName, 61);
                oEncrypt.Write(pSelectServer.encrypted_data, 0, pSelectServer.encrypted_data.Length);
                oEncrypt.FinalizeLengthAndChecksum();
                con.Close();
                m_cClientBase.CreateGameServerSession(oEncrypt, conf, m_szName);
                break;

            default:
                break;
            }
            return(packet);
        }
Beispiel #4
0
        /// <summary>
        /// Sends a Message in game
        /// </summary>
        /// <param name="szSource">Receiver</param>
        /// <param name="szMsg">Message</param>
        /// <param name="nType">Message Type (whisper, global, advertisment, [...]</param>
        /// <returns></returns>
        public void CreateMessagePacket(string szSource, string szMsg, int nType)
        {
            PacketOut o = new PacketOut(20);

            o.FillString(szSource, 21);
            o.WriteByte(0);
            o.WriteByte((byte)szMsg.Length);
            o.WriteByte((byte)nType);
            o.WriteString(szMsg, szMsg.Length);
            o.FinalizeLengthAndChecksum();
            m_cGameConnection.SendTCP(o);
        }
Beispiel #5
0
        /// <summary>
        /// Not sure about the content - but it actually sends your GPU with its driver version.
        /// </summary>
        /// <returns></returns>
        private PacketOut CreateReportPacket()
        {
            PacketOut o = new PacketOut(8000);

            o.WriteShort(8704);
            o.WriteShort(18197);
            o.WriteByte(81);
            o.WriteByte(251);
            o.WriteString("Windows  (6.2.9200)|ATI Radeon HD 3600 SeriesDrv Version : 8.17.10.1129", 71);   // Only for testing. And yes, my GPU sucks. Problem?
            o.FinalizeLengthAndChecksum();
            return(o);
        }
Beispiel #6
0
        /// <summary>
        /// Sends a ping packet to the server, keeping the connection alive.
        /// </summary>
        /// <returns>Nothing</returns>
        private void SendPingPacket()
        {
            // As long as there is a connection to the game server (sorry for the checks xP)
            while (m_cGameConnection != null && m_cGameConnection.Socket != null && m_cGameConnection.Socket.Connected)
            {
                PacketOut o = new PacketOut(9999);
                o.FinalizeLengthAndChecksum();
                m_cGameConnection.SendTCP(o);

                XLog.Debug("Ping packet sent.");
                System.Threading.Thread.Sleep(1000 * 60);
            }
            m_tPingThread.Abort();
        }
Beispiel #7
0
 /// <summary>
 /// Logs your character into the game
 /// </summary>
 /// <param name="nIndex">Selected Character Index</param>
 /// <returns></returns>
 public void CreateLoginPacket(int nIndex)
 {
     try {
         PacketOut oLogin = new PacketOut(1);
         oLogin.FillString(m_iGameCharacterList.nList[nIndex - 1].szName, 61);
         oLogin.WriteByte((byte)m_iGameCharacterList.nList[nIndex - 1].nRace);
         oLogin.FinalizeLengthAndChecksum();
         m_dHandles.Add(0, m_iGameCharacterList.nList[nIndex - 1].szName);
         m_cGameConnection.SendTCP(oLogin);
         XLog.AddMessage("", "", -5);   // Clear box
     }
     catch (Exception e) {
         XLog.Log("Error while logging in to the server: {0}", e.Message);
     }
 }
Beispiel #8
0
        /// <summary>
        /// Safe method of logging you out
        /// </summary>
        /// <returns></returns>
        private void CreateLogoutPacket()
        {
            PacketOut o = new PacketOut(27);

            o.FinalizeLengthAndChecksum();
            m_cGameConnection.SendTCP(o);
            m_cGameConnection.Disconnect();
            if (m_tPingThread != null && m_tPingThread.ThreadState == System.Threading.ThreadState.Running)
            {
                m_tPingThread.Abort();
            }
            if (IsConnected)
            {
                m_cGameConnection.Disconnect();
            }
        }