Exemplo n.º 1
0
        private void btnStart_MouseUp(object sender, MouseEventArgs e)
        {
            btnStart.Image = Properties.Resources.start_normal;

            UpdateProgress(100, "", false);

            if (string.IsNullOrWhiteSpace(tbAccount.Text))
            {
                MessageBox.Show("Please fill in your accountname!");
                UpdateProgress(100, "", true);

                FocusAccount();
                return;
            }

            if (string.IsNullOrWhiteSpace(tbPassword.Text))
            {
                MessageBox.Show("Please fill in your password!");
                UpdateProgress(100, "", true);

                FocusPassword();
                return;
            }

            if (string.IsNullOrWhiteSpace(tbAccount.Text))
            {
                MessageBox.Show("Please fill in all fields!");
                UpdateProgress(100, "", true);

                FocusAccount();
                return;
            }

            if (m_ServerGroup.Crowdedness == 0)
            {
                MessageBox.Show("Server is under examination. Try logging in later.");
                UpdateProgress(100, "", true);
                return;
            }

            MSG_PC_CONNECT_LOGIN msgLogin = new MSG_PC_CONNECT_LOGIN();

            msgLogin.LoginType            = 0; // Direct Login
            msgLogin.AccountName          = tbAccount.Text.ToNativeString(20);
            msgLogin.Password             = MD5Lib.GetPasswordMD5(tbPassword.Text);
            msgLogin.FieldServerGroupName = m_ServerGroup.ServerGroupName;
            msgLogin.PrivateIP            = Operations.GetLocalIPAddress().ToNativeString(16);
            msgLogin.MGameSEX             = 0;
            msgLogin.MGameYear            = 0;
            msgLogin.WebLoginAuthKey      = tbPassword.Text.ToNativeString(30);
            msgLogin.MACAddr = Operations.GetMacAddress().GetAddressBytes();

            m_Sock.SendPacket(Protocols.T_PC_CONNECT_LOGIN, msgLogin);
        }
Exemplo n.º 2
0
        private void OnReceivedPacket(object sender, PacketEventArgs e)
        {
            int    nBytesUsed = 0;
            ushort nRecvType  = 0;

            while (nBytesUsed < e.Length)
            {
                nRecvType   = BitConverter.ToUInt16(e.Data, nBytesUsed);
                nBytesUsed += 2;
                switch (nRecvType)
                {
                case Protocols.T_PC_CONNECT_GET_SERVER_GROUP_LIST_OK:
                {
                    MSG_PC_CONNECT_GET_SERVER_GROUP_LIST_OK Info = Operations.ByteArrayToStruct <MSG_PC_CONNECT_GET_SERVER_GROUP_LIST_OK>(e.Data, ref nBytesUsed);

                    if (Info.NumOfServerGroup == 0)
                    {
                        MessageBox.Show("Gameserver is offline!\nPlease check [http://ace.gaming-paradise.net] for further information!");
                        Exit();
                    }

                    if (Info.ServerGroup.Crowdedness <= 0)
                    {
                        UpdateProgress(0, "Gameserver offline", false);

                        System.Threading.Thread.Sleep(5000);

                        m_Sock.SendPacket(Protocols.T_PC_CONNECT_GET_SERVER_GROUP_LIST);

                        continue;
                    }

                    m_ServerGroup = Info.ServerGroup;

                    MSG_PC_CONNECT_SINGLE_FILE_VERSION_CHECK Msg = new MSG_PC_CONNECT_SINGLE_FILE_VERSION_CHECK();
                    Msg.DeleteFileListVersion = new ushort[] { 0, 0, 0, 0 };
                    Msg.NoticeVersion         = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_SINGLE_FILE_VERSION_CHECK, Msg);
                }
                break;

                case Protocols.T_PC_CONNECT_SINGLE_FILE_UPDATE_INFO:
                {
                    MSG_PC_CONNECT_SINGLE_FILE_UPDATE_INFO Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_SINGLE_FILE_UPDATE_INFO>(e.Data, ref nBytesUsed);

                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_SINGLE_FILE_VERSION_CHECK_OK:
                {
                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_REINSTALL_CLIENT:
                {
                    MSG_PC_CONNECT_REINSTALL_CLIENT Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_REINSTALL_CLIENT>(e.Data, ref nBytesUsed);

                    // Use current version, we don't need the update thingy
                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = Msg.LatestVersion;

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_VERSION_OK:
                {
                    UpdateProgressCallback callback = UpdateProgress;
                    FileCheck.GetHashList(callback);
                }
                break;

                case Protocols.T_PC_CONNECT_LOGIN_OK:
                {
                    MSG_PC_CONNECT_LOGIN_OK Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_LOGIN_OK>(e.Data, ref nBytesUsed);

                    if (Properties.Settings.Default.StoreLogins)
                    {
                        Properties.Settings.Default.AccountName = tbAccount.Text;
                        Properties.Settings.Default.Password    = tbPassword.Text;
                        Properties.Settings.Default.Save();
                    }

                    string Args = String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"
                                                , Msg.FieldServerIP.ToManagedString()
                                                , Msg.FieldServerPort
                                                , Msg.IMServerIP.ToManagedString()
                                                , Msg.IMServerPort

                                                , Msg.AccountName.ToManagedString()
                                                , BitConverter.ToString(MD5Lib.GetPasswordMD5(tbPassword.Text)).Replace("-", "").ToLowerInvariant()

                                                , (Properties.Settings.Default.Fullscreen) ? 1 : 0
                                                , Properties.Settings.Default.Width
                                                , Properties.Settings.Default.Height
                                                , 2

                                                , (Msg.ConnectToTestServer) ? 1 : 0

                                                , (Properties.Settings.Default.UseVSync) ? 1 : 0);

                    ProcessStartInfo pInfo = new ProcessStartInfo();
                    pInfo.FileName  = "ca.exe";
                    pInfo.Arguments = Args;

                    Process.Start(pInfo);

                    Environment.Exit(0);
                }
                break;

                case Protocols.T_PC_CONNECT_LOGIN_BLOCKED:
                {
                    MSG_PC_CONNECT_LOGIN_BLOCKED Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_LOGIN_BLOCKED>(e.Data, ref nBytesUsed);

                    if (Msg.IsMacBlocked)
                    {
                        MessageBox.Show("Your account is blocked presently.\n If you believe this is an error please Contact Customer Support at [http://gaming-paradise.net/support/] for further details");
                    }
                    else
                    {
                        string BlockedMsg = String.Format("{0}\'s account is blocked presently.\n  Reason: {1}\n  Period: {2} ~ {3}\n\nContact Customer Support at [http://gaming-paradise.net/support/] for further details."
                                                          , Msg.szAccountName.ToManagedString()
                                                          , Msg.szBlockedReasonForUser.ToManagedString()
                                                          , Msg.atimeStart.ToString()
                                                          , Msg.atimeEnd.ToString());
                        MessageBox.Show(BlockedMsg);
                    }
                }
                break;

                case Protocols.T_ERROR:
                {
                    MSG_ERROR ErrorMsg = Operations.ByteArrayToStruct <MSG_ERROR>(e.Data, ref nBytesUsed);

                    string Msg = Operations.GetChatMessageFromPacket(e.Data, ref nBytesUsed, ErrorMsg.StringLength);

                    ShowError(ErrorMsg, Msg);
                }
                break;

                default:
                {
                    MessageBox.Show("Got unknown data from server!");
                    Exit();
                }
                break;
                }
            }
        }